1.3.0 • Published 10 months ago

@pigsty/next-routes-list v1.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

next-routes-list

Forked from https://github.com/Emiyaaaaa/next-routes-list

Generate list of routes based on Next.js source code

Support

  • App routes
  • 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.

1.3.0

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago