Easy generate all available routes in Next.js .
- App routes
- Page routes
npm install --save-dev next-routes-list@latest
add script to package.json
:
{
"script": {
"generate-next-routes-list": "generate-next-routes-list"
}
}
If you use src
directory:
{
"script": {
"generate-next-routes-list": "cd src && npx generate-next-routes-list"
}
}
then run npm script:
npm run generate-next-routes-list
import { routes } from 'next-routes-list'
console.log(routes)
/**
[
'/',
'/about',
'/posts/[id]',
...
]
*/
next projct is here, generate result is: here.
feel free to contribute anything or report any issues.