constructor

FileSystemRouter.constructor

constructor FileSystemRouter(

Create a new FileSystemRouter.

@param options

The options to use when creating the router

const router = new FileSystemRouter({
  dir: process.cwd() + "/pages",
  style: "nextjs",
});

const {params} = router.match("/blog/2020/01/01/hello-world");
console.log(params); // {year: "2020", month: "01", day: "01", slug: "hello-world"}

Referenced types

interface FileSystemRouterOptions

Options for the FileSystemRouter constructor.

  • assetPrefix?: string

    The base path to use when routing

  • dir: string

    The root directory containing the files to route

  • fileExtensions?: string[]

    Limit the pages to those with particular file extensions.

  • origin?: string
  • style: 'nextjs'

class FileSystemRouter

Resolve routes against a directory of files using Next.js-style (pages directory) conventions.