Edit this page

Router

The @lazarv/react-server framework includes a file-system based router which is building on top of the framework's own low-level routing solutions and it's very easy to use and configure. If you think this router is too much for your needs, you can use the built-in low-level server-side router and client-side navigation components of the framework or use a third-party router like React Router or TanStack Router. You can check out the examples collection on how to use these third-party routers.

Using the file-system based router is extremely easy and simple. You just omit the entrypoint when using the react-server CLI and the router will be used automatically.

You can learn about how to define your routes and how to configure the router to create layouts, pages and different types of routes like nested routes, dynamic routes and catch-all routes.

You can also create outlets to create reusable parts of your application that can be used in different layouts, whileerror handling and loading components are also supported in the router.

This router also supports creating middlewares and API route handlers to create middlewares and API endpoints using the file-system and all the rules you already learned when creating pages and layouts.

This documentation is also the best example that you can use Markdown or MDX files as pages in your application. This is a very simple way to create static pages in your application.

Next you can learn how to generate a static website using the combination of the router and the framework. You can define all the routes you want to generate and the router will generate the static files for you. Not only for pages, but any static file, like a sitemap.xml for your website.

Finally learn how to configure the router to fit your needs. You can define the root path for your routes, the public path for your static files and you can include specific files in the routing or exclude files and directories from the routing using glob patterns.