Pattern for Next.js path strings (App Router)

Does anyone have a good strategy for handling the paths to different pages in next? I'm using the app router but I moved some files around which adjusted the url paths for all the pages, and now I'm paranoid that I have dangling hrefs and router.push-es pointing to the old paths. Makes me think there has to be a better way to manage the strings of where things are routed. Long ago in my Ruby on Rails days they had amazing path helpers where you would never link or reference any path directly you would call a helper that would generate the path string and that way you never had to worry about linking to old paths. Anyways, anyone know a good way of handling this in next+app router? Maybe there's something obvious I'm missing.
5 Replies
Neto
Neto2y ago
there are some options for that
Neto
Neto2y ago
next-typesafe-url
next-typesafe-url
a search param and routing library for next.js
Neto
Neto2y ago
iirc vercel seems to be working with something for that but nothing concrete for now
Spaceman
SpacemanOP2y ago
Thanks for this! This led me down a rabit hole and I also found this solution which is a bit less typesafe but seems a bit more plug and play: https://github.com/tatethurston/nextjs-routes Still deciding on which one to go with.
GitHub
GitHub - tatethurston/nextjs-routes: Type safe routing for Next.js
Type safe routing for Next.js. Contribute to tatethurston/nextjs-routes development by creating an account on GitHub.
Want results from more Discord servers?
Add your server