Route Generation
Resolid offers two approaches to defining routes:- Flex Routes - Convention-based file system routing
- Relative Factory - Programmatic route definition with relative paths
Flex Routes
Flex routes automatically generate route configurations from your file system structure.Setup
resolid.config.ts
Options
File Conventions
Flex routes support these file extensions:.js,.jsx.ts,.tsx.md,.mdx
Route Files
File names map to URL paths:Dynamic Segments
Prefix with$ for dynamic route parameters:
$ at the end becomes a splat route:
Index Routes
Files named_index create index routes:
Layout Routes
Files ending with_layout create layout routes:
Pathless Routes
Prefix with_ to create pathless routes:
Escaped Characters
Use[] to escape special characters:
Optional Segments
Use() for optional route segments:
Route Manifest
Flex routes convert files into a route manifest:Conflict Resolution
When multiple files resolve to the same route:Relative Factory
The relative factory enables programmatic route definitions with path resolution relative to a directory.Setup
API
The factory returns three functions that mirror React Router’s route helpers:route(path, file, children?)
Define a route with a path:
index(file, children?)
Define an index route:
layout(file, children?)
Define a layout route:
Path Resolution
All file paths are resolved relative to the factory’s directory:Advanced Patterns
Nested Routing
Combine layouts and child routes:Route Groups
Organize routes without affecting URLs:Mixed Approach
Combine flex routes with manual routes:resolid.config.ts
Route Metadata
Access route information in your components:Route Configuration Example
A complete route configuration:resolid.config.ts
TypeScript Support
React Router generates types for your routes automatically. Import them using the+types convention:
routes/blog/$slug.tsx