Next.js Discord

Discord Forum

best practices : route with parameter

Answered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
Hi community

I am building a booking page.
When visitors like the product and gives some extra information and clicks book now button.

I want it to be forwarded to booking page component. Where it gets all the information given by visitors.

How can i do that ?
Using link ? Or useRouter() hook

Little confused here
With the new changes with next/navigation
Instead of next/router
Answered by B33fb0n3
If I would be you, I would just do that clientside. The form (where the client gives some extra information) is normally clientside and so should the send action be clientside. The user would normally execute a server action (serverside mutation initiated by client), to do stuff serverside (in your example to create a booking I guess). So there is no need to redirect
View full answer

11 Replies

@Cape lion Hi community I am building a booking page. When visitors like the product and gives some extra information and clicks book now button. I want it to be forwarded to booking page component. Where it gets all the information given by visitors. How can i do that ? Using link ? Or useRouter() hook Little confused here With the new changes with next/navigation Instead of next/router
If I would be you, I would just do that clientside. The form (where the client gives some extra information) is normally clientside and so should the send action be clientside. The user would normally execute a server action (serverside mutation initiated by client), to do stuff serverside (in your example to create a booking I guess). So there is no need to redirect
Answer
@Cape lion thanks for the comment would you be using <Link> component for it ?
In my personal projects, I execute a function (onClick event), when the user clicks for example a button
@Cape lion and you won't be using useRouter() hook?
No. As I said: I would call a function that does the stuff, that you are trying to do when redirecting. So: use a function, that executes, what you want to do serverside and throw away the idea of redirecting the user. Of course you can still redirect the user after your function is done, to show him for example a „finish booking“ page
@Cape lion makes sense now thanks yeah . will implement that ; )
Sure thing. Please mark solution
Cape lionOP
How to mark it as solution?
Thought it would do automatically here
Original message was deleted
no you have to do this