Skip to main content
This API is intended primarily for library authors. It supports only Next.js-style file-system routing.

Next.js-style

The FileSystemRouter class resolves routes against a pages directory. (The Next.js 13 app directory is not supported.) Consider the following pages directory:
To resolve routes against this directory:
router.ts
Query parameters are parsed and returned in the query property.
The router parses URL parameters and returns them in the params property:
The .match() method also accepts Request and Response objects; their url property is used to resolve the route.
The router reads the directory contents on initialization. To re-scan the files, use the .reload() method.

Reference