generate next all routes list
Easy generate all available routes in Next.js .
- [x] App routes
- [x] Page routes
``bash`
npm install --save-dev next-routes-list@latest
add script to package.json:
`json`
{
"script": {
"generate-next-routes-list": "generate-next-routes-list"
}
}
If you use src directory:
`json`
{
"script": {
"generate-next-routes-list": "cd src && npx generate-next-routes-list"
}
}
then run npm script:
`shell`
npm run generate-next-routes-list
`ts
import { routes } from "next-routes-list";
console.log(routes);
/**
[
'/',
'/about',
'/posts/[id]',
...
]
*/
`
| Option | Type | Description | Example |
| ------ | ------ | ------------------------------- | -------------------------------------------- |
| -o | string | set the output routes file path | npx generate-next-routes-list -o routes.ts` |
next projct is here, generate result is: here.
feel free to contribute anything or report any issues.