Several pages on same url #12697
-
I am quite new to NextJs and have to implement a step-by-step process and would like to display each page of the process, e.g. step1, step2, step3, under the same url "/process". I found out that this can be done with
and as is "/process". However, I wonder if this has any major drawbacks and if there is a better alternative, which is as simple as the use of Thx in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The problem with this approach is that as soon as you refresh the page (F5) it will give you a 404 since these pages don't really exist. Can these steps be individually accessible? In other words, can I directly access If you need to access If every time you access any of the steps you need to start again, do you really need this info in the URL? If you do (perhaps for navigating using the browser back/forward buttons) then you might want to consider using hashes: |
Beta Was this translation helpful? Give feedback.
The problem with this approach is that as soon as you refresh the page (F5) it will give you a 404 since these pages don't really exist.
Can these steps be individually accessible? In other words, can I directly access
process/step2
? If yes, then you can use acatch all route
likeprocess/[...step]
.If you need to access
step1
beforestep2
, you can use cookies (for SSR) or local storage to keep track of the visited pages and redirect if necessary, but if this is viable or not will depend on your requirements.If every time you access any of the steps you need to start again, do you really need this info in the URL? If you do (perhaps for navigating using the browser back/forward buttons) …