@pigsty/next-routes-list
v1.3.0
Published
generate next all routes list
Downloads
439
Maintainers
Readme
next-routes-list
Forked from https://github.com/Emiyaaaaa/next-routes-list
Generate list of routes based on Next.js source code
Support
- [x] App routes
- [x] Page routes
Install
pnpm add next-routes-list -D
Usage
1. Run script
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
2. Import routes
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]',
...
]
*/
Example
next projct is here, generate result is: here.
Contribute
feel free to contribute anything or report any issues.