Skip to main content
This API is primarily intended for library authors. At the moment only Next.js-style file-system routing is supported, but other styles may be added in the future.

Next.js-style

The FileSystemRouter class can resolve routes against a pages directory. (The Next.js 13 app directory is not yet supported.) Consider the following pages directory:
The FileSystemRouter can be used to resolve routes against this directory:
router.ts
Query parameters will be parsed and returned in the query property.
The router will automatically parse URL parameters and return them in the params property:
The .match() method also accepts Request and Response objects. The url property will be used to resolve the route.
The router will read the directory contents on initialization. To re-scan the files, use the .reload() method.

Reference