@nicnocquee/next-type-safe-routing
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @nicnocquee/next-type-safe-routing

Weekly Downloads

2

Version

0.0.4

License

MIT

Unpacked Size

20.6 kB

Total Files

12

Last publish

Collaborators

  • nicnocquee