Next.js Discord

Discord Forum

Using UUIDs in URL. Bad practice?

Unanswered
Scale parasitoid posted this in #help-forum
Open in Discord
Scale parasitoidOP
I am developing an admin dashboard for my website, and I am using UUIDs in the URL to determine which user's data to fetch from database.

The folder structure in my project looks like this

src -> app -> user -> [userId] -> page.jsx

userId contains the UUID.

Is this bad practice? What could be an alternative solution?

4 Replies

Spectacled bear
I don't think its a bad practice, infact its a secure one. One can't just try to fetch another user even if they manipulate the id since uuid patterns are not continious.
Eastern Kingbird
Generally good practice to do. I sometimes also like to include a searchable name in the URL as well. Like UUID/user-name that way if someone searches in their search bar, it can be found in their search history by their browser.
You see this a lot in the wild. Here's an example of a searchable name, then an ID, even though only the ID is technically needed.
Spectacled bear
Correct, apart from id, you can make everything optional but can add other fields like name or other properties for better user experience.