How to use url slug instead of id #66932
Answered
by
icyJoseph
khuongviettai
asked this question in
App Router
-
I want to create a website but I don't know how to use the url according to the product name instead of the product id. How can I fetch the exact product I choose? for example, i want the url to be: /products/t-shirt instead of /products/123 |
Beta Was this translation helpful? Give feedback.
Answered by
icyJoseph
Jun 17, 2024
Replies: 1 comment 3 replies
-
The API you use to get products from you database, or other source of truth, has to be able to do a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then you should've designed it, so that they are unique 😅
You could also maybe do
t-shirt---id
or something like that, and then split on---
to collect theid
. In general, append something to the end of the URL, which you can use to figure out which product to show. Keep them short though.