Forked from https://github.com/Emiyaaaaa/next-routes-list
Generate list of routes based on Next.js source code
- [x] App routes
- [x] Page routes
pnpm add next-routes-list -D
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
TODO: incomplete readme, but basically you can call getNextRoutesWithMatchers
and have a list of all routes + regular expression that you can use to test URL.pathname
import { getNextRoutesWithMatchers } from 'next-routes-list'
console.log(getNextRoutesWithMatchers())
/**
[
'/',
'/about',
'/posts/[id]',
...
]
*/
next projct is here, generate result is: here.
feel free to contribute anything or report any issues.