Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js routing: base dynamic slug / static slug

I have a situation where at the base of the url I have a dynamic slug that fetches data. Now I find I need a static slug after that which will signify a different page but still can access the base dynamic slug for information.

Example Paths

/formABC (page1)

/formABC/complete (page2)

page1 fetches data based on the dynamic slug but knows it isn't on the "complete" page

page2 fetches data based on the dynamic slug (formABC) but knows it's on the complete page

Current Folder Structure

pages/
  [formName].js

So 1, is this possible with next.js?

And 2 any jumping-off points I should try (file structure, predefined next methods)?

like image 628
David Jarrin Avatar asked Oct 27 '25 06:10

David Jarrin


1 Answers

That's possible with the following folder structure:

pages/
  [formName]/
     complete.js
     index.js

With each pages having its own data fetching method.

like image 124
juliomalves Avatar answered Oct 29 '25 05:10

juliomalves



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!