This example shows to install and run the routes-gen
script with the Remix driver. There are also a couple of routes for showcasing the usage of the generated type-safe route
helper.
Open this example on CodeSandbox:
In this example, we've installed routes-gen
and @routes-gen/remix
.
For convenience, we've added the routes-gen
script to our package.json
, so we wouldn't have to specify the Remix driver each time we generated the routes typings.
This example has 3 routes:
/
/products
/products/:productId
You can see the typings for these routes in app/routes.d.ts
, which will be generated automatically by running npm run routes-gen
. Do not edit this file manually, since it will be overwritten next time you run the script.
If you'll take a look at the source of the routes, you'll see how the route
helper is used for a type-safe route usage.
Go ahead and create a couple of new routes, both with and without dynamic parameters. After that, run npm run routes-gen
and you'll see that the route
method now has typings for all the new routes.