strict-routes
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.2 • Public • Published

strict-routes

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.

Usage

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 });

Installation

yarn add strict-routes
npm install strict-routes

TypeScript Version

Because strict-routes is using template literal types it works with TypeScript 4.1 or newer.

Readme

Keywords

none

Package Sidebar

Install

npm i strict-routes

Weekly Downloads

2

Version

1.0.0-rc.2

License

MIT

Unpacked Size

3.55 kB

Total Files

6

Last publish

Collaborators

  • anemone
  • hasparus