Dynamic Routing
Answered
American Crocodile posted this in #help-forum
American CrocodileOP
Hey, i have a question about dynamic route
My goal with dynamic is like this
localhost:300/order/house
localhost:300/order/shoe
localhost:300/order/car
So i want make the url after order is dynamic, but someone go to
localhost:300/order/ it redirect to localhost:3000
Is it possible?
My goal with dynamic is like this
localhost:300/order/house
localhost:300/order/shoe
localhost:300/order/car
So i want make the url after order is dynamic, but someone go to
localhost:300/order/ it redirect to localhost:3000
Is it possible?
Answered by B33fb0n3
the useParams hook is only for clientside stuff. If he want to retrieve it serverside, he can do this directly through the params.
7 Replies
yes, add your dynamic fragement to your route config by creating a folder
[dynamic] and then check if the param is empty or not. When empty redirect to /@American Crocodile Hey, i have a question about dynamic route
My goal with dynamic is like this
localhost:300/order/house
localhost:300/order/shoe
localhost:300/order/car
So i want make the url after order is dynamic, but someone go to
localhost:300/order/ it redirect to localhost:3000
Is it possible?
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
/order/[order] and retrieve params using
/order/[order] and retrieve params using
useParams hook@Coffee Coke https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
/order/[order] and retrieve params using `useParams` hook
the useParams hook is only for clientside stuff. If he want to retrieve it serverside, he can do this directly through the params.
Answer
American CrocodileOP
Thank u, ima try it
American CrocodileOP
happy to help