@pigsty/next-routes-list
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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.

Package Sidebar

Install

npm i @pigsty/next-routes-list

Weekly Downloads

121

Version

1.3.0

License

ISC

Unpacked Size

9.74 kB

Total Files

13

Last publish

Collaborators

  • swiniak