Skip to content

nicnocquee/next-type-safe-routing

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published