ExtractRouteParams
A utility type that extracts route parameters from a URL path string, converting path segments like ':id' into typed properties.
Source
Type Definition
type ExtractRouteParams<T extends string> =
T extends `${string}:${infer Param}/${infer Rest}`
? { [K in Param]: string } & ExtractRouteParams<Rest>
: T extends `${string}:${infer Param}`
? { [K in Param]: string }
: {};
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
T | string | ✅ | - | The URL path string template containing parameter placeholders like ':id', ':name', etc. |
Last modified: 2025-06-10