Next.js Discord

Discord Forum

get parent path

Unanswered
Yacare Caiman posted this in #help-forum
Open in Discord
Yacare CaimanOP
Hi, is there a way in a page to get the parent path in a page component? for example blog from /blog/[slug],

I found usePathname() but it requires "use client", is there an alternative way in the same way you get the params?
export default async function page({ params }: { params: { slug: string } }) {

5 Replies

Yacare CaimanOP
I made a bad example, let's say you have /blog/[section]/[slug]
anyway thanks
@Yacare Caiman I made a bad example, let's say you have /blog/[section]/[slug]
oh you can see ALL params not just the current level
so if in slug file you can see slug and section