get parent path
Unanswered
Yacare Caiman posted this in #help-forum
Yacare CaimanOP
Hi, is there a way in a page to get the parent path in a page component? for example
I found usePathname() but it requires "use client", is there an alternative way in the same way you get the params?
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 Caiman 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 } }) {
not in the page component. since its a static file you could simply hardcode it as it is not going to change. if its in a nested component its smarter to just use usePathname or prop drill
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