How to access (grand)parent params
Answered
Rhinelander posted this in #help-forum
RhinelanderOP
Let say I have url .../dashboard/[id]/something-else/child.
Can I use { params }: { params: { id: number } } to get id inside the child
Can I use { params }: { params: { id: number } } to get id inside the child
15 Replies
2 options: either use client components
or make parallel routes
RhinelanderOP
Can't use client.
U use authjs.dev v5 and i am authenticating
Answer
RhinelanderOP
Who is right?
well try it and see
RhinelanderOP
I tried and I guess it worked but i though it was bug
it's under [id] so can access the id in the params
RhinelanderOP
so if i have /[ID]/A/B/C/D/E/child i should be able to access it ?
yes
[id]/layout.tsx
[id]/a/b/c/layout.tsx
[id]/page.tsx
[id]/a/b/c/page.tsx
all can access id
[id]/a/b/c/layout.tsx
[id]/page.tsx
[id]/a/b/c/page.tsx
all can access id
yes you can access parent's id, not child id. my mistake