<aside> 🚧 Since the library is still in the development stage, it is not recommended to use it on production.
</aside>
The library allows you to set up isomorphic routing for the server-side rendered React application. It aims to provide a strongly typed and declarative way of defining the router related logic.
In your project’s directory, run:
npm i @ssr-tools/router
Then you can import createRouter
function:
import { createRouter } from "@ssr-tools/router/createRouter";
createRouter()
It’s the primary function of this library. It creates everything you may need for your router. Provide it with a configuration for the application's routes. It returns the functions to render routes on the client and the server. The returned functions derive the types from the given configuration, which allows TypeScript to identify possible routing errors.
To create a router, you need to import and call the createRouter
function. As the first and only argument, you provide the configuration.