Documentation
Preloading
Use route resources and prepare lifecycle for Suspense-friendly route data.
The router supports lazy route resources and a route prepare lifecycle. Use this to load code and derive route-specific data before rendering.
Preparation receives route context such as variables and filters. Keep prepare logic deterministic: it should depend on the matched route and URL state, not on ambient mutable state.
Practical guidance
- Keep route resources lazy where this improves bundle boundaries.
- Return only the route data the page needs.
- Use Suspense and explicit fallbacks for loading states.
- Clean up router instances in tests or disposable shells.