@nicnocquee/next-type-safe-routing
v0.0.4
Published
Utility to make next.js routing type safe.
Downloads
4
Readme
Type-safe Next Routing
Utility to make next.js routing type safe. Based on https://www.flightcontrol.dev/blog/fix-nextjs-routing-to-have-full-type-safety. The project is initiated with typescript-starter.
Installation
npm i next-type-safe-routing
Usage
import { z } from 'zod';
export const OrgParams = z.object({ orgId: z.string() });
export const Routes = {
home: makeRoute(({ orgId }) => `/org/${orgId}`, OrgParams),
};
import Link from 'next/link'
import {Routes} from '../../routes.ts'
<Link href={Routes.home({orgId: 'someId'})} />
Developing
npm run watch:build
- To test:
npm run test