@repo/route-kit offers type-safe route definitions with Zod. It exports defineRoute, which builds Route objects from optional Zod params and search schemas and provides typed path() and href() helpers. It also exports the RouteParams and RouteSearch utility types.
graph TD
routekit["@repo/route-kit"]
routekit -.-> tsconfig["@repo/typescript-config"]
routekit -.-> vitest["@repo/vitest-config"]import { z } from "zod";
import { defineRoute } from "@repo/route-kit";
const clientRoute = defineRoute({
params: z.object({ id: z.string() }),
path: (params) => `/clients/${params.id}`,
});
clientRoute.path({ id: "abc" }); // "/clients/abc"
clientRoute.href({ id: "abc" }); // "/clients/abc"
const searchRoute = defineRoute({
params: z.object({ id: z.string() }),
search: z.object({ tab: z.string().optional() }),
path: (params) => `/clients/${params.id}`,
});
searchRoute.href({ id: "abc" }, { tab: "notes" }); // "/clients/abc?tab=notes"