Utility types
To easily extract routes types, use InferRoutes
:
import { createRouter, InferRoutes } from "@swan-io/chicane";
export const Router = createRouter({
UserList: "/users",
UserDetail: "/users/:userId",
});
// A map of route names and their associated params
type Routes = InferRoutes<typeof Router>;
export type RouteName = keyof Routes;
export type RouteParams<T extends RouteName> = Routes[T];