zero-cost strictly typed routing in TypeScript
Have you ever broken a link in your app with a stupid typo or by overlooking? No more.
import { strictRoutes } from 'strict-routes';
type Routes =
| '/'
| 'posts/{postId}'
| 'posts/{postId:number}/{commentId:string}'
const { navigate } = strictRoutes<Routes>()({
navigate:
})
navigate({ path: 'posts/{postId}', postId: 1 });
yarn add strict-routes
npm install strict-routes
Because strict-routes
is using template literal types it works with TypeScript 4.1 or newer.