Next.js Discord

Discord Forum

Accessing dynamic route params from neighbor layout.tsx

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
I'm working on a dashboard which lets users manage their Stores. each user can have more than one store.

There is a tab on dashboard's navbar which shows user's stores and when user clicks on each of them dashboard shows data only related to that store.

currently I'm achieving this by using dynamic routes, basically each store has it's own dynamic route for example: /store1/dashboard/insights , /store2/dashboard/insights

the problem with this is that the dashboard's layout is also under [storeId] route, which means every time user selects one of the stores the whole page(layout included) will rerender.

I was wondering if there is any better solution to this problem like accessing [storeId] params from a neighbor layout.tsx file like this:

/dashboard
---[storeId]
---layout.tsx (want to access storeId params here)

Any other solution is welcome

0 Replies