generateTypedRoutes option.
Signature
Parameters
Record<string, Record<string, string>>
required
Type parameter representing the mapping of route paths to their parameter types.This is typically auto-generated by the vite-plugin as
RouteParams.Return Type
TypedPaths<TRoutes>
An object with a
for() method for building type-safe paths.function
Build a URL path with type-checked parameters.Parameters:
path: string- Route path template (can include?querysuffix)params?: Record<string, string>- Path parameters (required if route has dynamic segments)
Examples
Basic Setup
Static Routes
Dynamic Routes
Routes with Query Strings
URL Encoding
Catch-all Routes
Type Safety
Usage in Navigation
Programmatic Navigation
Building URLs from Data
TypeScript Types
Implementation Details
Path Parameter Replacement
Thefor() method replaces dynamic segments in the path template:
- Dynamic segments (
:paramName): Replaced with the encoded parameter value - Catch-all segments (
*paramName): Replaced with the parameter value, encoding each path segment individually while preserving slashes
URL Encoding
- Dynamic segments (
:param) are encoded usingencodeURIComponent(), which encodes the entire value including slashes - Catch-all segments (
*param) split the value on/, encode each segment individually, then rejoin with/to preserve path structure
Notes
- This function is designed to work with auto-generated route types from the vite-plugin
- Path parameters are automatically URL-encoded
- Query strings can be included in the path template using
?syntax - TypeScript will enforce that all required parameters are provided with correct types
- Empty parameter objects (
{}) indicate routes with no dynamic segments
Related
- Routing & Navigation - Understanding AppShell’s routing system
- File-based Routing - Using the vite-plugin for file-based routes