Next.js Discord

Discord Forum

URL, ReactContext, Server for Dashboard?

Answered
Da_v_id posted this in #help-forum
Open in Discord
Avatar
Hi, I am building a dashboard for different projects with a projectSwitcher (I am just using Shadcn's sidebar07), and I was just wondering how should i track the selected project to render the right dashboard? should i store the ID in the URL? should i store it as a react Context + local storage? or add an entry in the database?
Answered by James4u (Tag me if needed)
@Da_v_id well I would suggest to store the id in the url.
View full answer

7 Replies

Avatar
@Da_v_id well I would suggest to store the id in the url.
Answer
Avatar
you can also just use a state/context but I don't see any cons of using id in the url
https://nuqs.47ng.com/
check out above library ⬆️ (I don't mean only search params you can also use dynamic routing if it's okay e.g gmail with several accounts)
Avatar
@Da_v_id any opinion?
Avatar
apologises for the late response! Yea that makes totally sense, do you know if nuqs helps with queryParams as well? or just Search Query?
Avatar
what do you mean by query param vs search query? I think they are the same.
or did you mean dynamic path slug?
Avatar
oh right i meant dynamic path slug