Next.js Discord

Discord Forum

Best approach for multi step form?

Answered
Scarlet Tanager posted this in #help-forum
Open in Discord
Scarlet TanagerOP
Should I create new route for each step of form for example I have 4 steps form should we create 4 routes or render the whole 4 multi step form in one route?

11 Replies

@Scarlet Tanager Should I create new route for each step of form for example I have 4 steps form should we create 4 routes or render the whole 4 multi step form in one route?
if I would be you, I would check my use case and where and how the data be saved. If it's for example a database and you have a table like "start questions" and each questions can have many answers, I would do that (route approach). But if it's like a database and you have one user object and there a keys for something like "role", I would do it via a clientside multi step form
@B33fb0n3 if I would be you, I would check my use case and where and how the data be saved. If it's for example a database and you have a table like "start questions" and each questions can have many answers, I would do that (route approach). But if it's like a database and you have one user object and there a keys for something like "role", I would do it via a clientside multi step form
Scarlet TanagerOP
I have external backend in php and client in nextjs when we fill each step all that data for that step needs to be saved because if user leaves the page and come back the data needs to be there not to be filled over again
... that step needs to be saved ...
Then you can do it with the route approach, but keep in mind to have a clean redirect flow then. If you don't know how, you can still use a clientform
@Scarlet Tanager solved?
Scarlet TanagerOP
I didn’t try yet
@Scarlet Tanager I didn’t try yet
American Crow
i did a proof of concept for a muli step multi route form recently. If you need the code i could separate it out in a repo. Let me know
Answer