@tanstack/react-router
>=1.0.0 <2.0.0postconditions32functions15last verified2026-06-24coverage score100%Postconditions: what we check
- useNavigate · invalid-route-pathwarningWhenNavigation target route does not existThrows
Error indicating route not foundRequired handlingCaller SHOULD handle navigation errors with error boundary or try-catch if using navigate programmatically. Invalid routes will throw at runtime. TypeScript type checking enforces valid route paths at compile time — TypeScript users with strict route types satisfy this requirement statically.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - useNavigate · navigation-during-unmountwarningWhenNavigation is triggered after component unmountsThrows
Error indicating component is unmountedRequired handlingCaller MUST either cleanup navigation side effects or use error boundary to catch unmount errors. Common in async navigation (e.g., after API call completes).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - useNavigate · invalid-paramserrorWhenNavigation params do not match route's param typesThrows
Error indicating invalid params for target routeRequired handlingCaller MUST ensure params match the target route's expected types. TypeScript types help but runtime validation still needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1] - useMatch · route-mismatch-stricterrorWhenCurrent route doesn't match 'from' parameter when strict: trueThrows
Error indicating route mismatchRequired handlingCaller MUST either use correct 'from' route, set strict: false for shared components, or wrap in error boundary to handle mismatch gracefully.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - useMatch · route-not-founderrorWhenRoute specified in 'from' parameter does not existThrows
Error indicating route not foundRequired handlingCaller MUST ensure route exists before calling useMatch with that route. Verify route is registered in router configuration.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[4] - useLoaderData · loader-error-unhandlederrorWhenRoute loader throws an error during data loadingThrows
Error from loader functionRequired handlingCaller MUST implement ErrorComponent in route definition or parent route to catch loader errors. Without error boundary, loader errors crash the app.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[5] - useLoaderData · loader-data-unavailableerrorWhenLoader data is accessed before loader completesThrows
Error indicating data not yet loadedRequired handlingCaller MUST handle Suspense boundaries properly. useLoaderData throws when data is not yet available, triggering Suspense.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - useLoaderData · no-loader-definederrorWhenuseLoaderData called on route without loader functionThrows
Error indicating no loader defined for routeRequired handlingCaller MUST ensure route has loader function defined before calling useLoaderData. Check route configuration.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - useParams · param-type-mismatchwarningWhenActual param value doesn't match expected type from route definitionThrows
Error indicating type mismatchRequired handlingCaller SHOULD validate params match expected types. TanStack Router v1 with strict TypeScript types validates params at compile time. Runtime validation adds defense-in-depth but may not be required when TypeScript enforces the type contract.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - useParams · required-param-missingerrorWhenRequired route param is missing or undefinedThrows
Error indicating required param missingRequired handlingCaller MUST ensure all required params are provided when navigating to route. Check route configuration for required params.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - useSearch · search-schema-validation-errorwarningWhenSearch params don't match route's search schema validationThrows
Error with validation detailsRequired handlingCaller SHOULD handle search param validation errors with error boundary. Use validateSearch option in route to define validation schema. When validateSearch uses a Zod schema, the validation itself satisfies this requirement — the schema ensures params are validated before use.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - useSearch · search-param-parse-errorerrorWhenSearch param value cannot be parsed to expected typeThrows
Error indicating parse failureRequired handlingCaller MUST validate search param types. URL strings may not match expected types (e.g., number, boolean, array).costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - useRouteContext · context-not-availableerrorWhenRoute context accessed before route provides contextThrows
Error indicating context not availableRequired handlingCaller MUST ensure route or parent route provides context via beforeLoad or context option. Wrap in error boundary or provide fallback.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[7] - useRouteContext · route-mismatch-strict-contexterrorWhenCurrent route doesn't match 'from' parameter when strict: trueThrows
Error indicating route mismatchRequired handlingCaller MUST use correct 'from' route or set strict: false for shared components.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - createRouter · duplicate-route-pathserrorWhenMultiple routes defined with same pathThrows
Error indicating duplicate route pathRequired handlingCaller MUST ensure all route paths are unique within router configuration. Check for conflicting route definitions.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[8] - createRouter · invalid-route-hierarchyerrorWhenRoute hierarchy is invalid (e.g., child route without parent)Throws
Error indicating invalid route treeRequired handlingCaller MUST ensure route hierarchy is valid with proper parent-child relationships. Wrap createRouter in try-catch during initialization.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[8] - createRouter · missing-root-routeerrorWhenRouter configuration missing root routeThrows
Error indicating no root route definedRequired handlingCaller MUST provide root route using createRootRoute or createRootRouteWithContext.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[8] - Navigate · invalid-route-navigateerrorWhenNavigate component targets non-existent routeThrows
Error indicating route not foundRequired handlingCaller MUST ensure target route exists before rendering Navigate component. Wrap in error boundary to prevent crashes.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[4] - Navigate · navigate-infinite-looperrorWhenNavigate component causes infinite navigation loopThrows
Error indicating max navigation depth exceededRequired handlingCaller MUST avoid navigation loops by checking conditions before rendering Navigate. Use replace prop to prevent history stack overflow.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - Link · invalid-route-linkerrorWhenLink component targets non-existent routeThrows
Error indicating route not foundRequired handlingCaller MUST ensure target route exists. Invalid links throw at render time. Use error boundary to catch link errors.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - Link · invalid-link-paramserrorWhenLink params don't match target route's param typesThrows
Error indicating invalid paramsRequired handlingCaller MUST ensure link params match target route's expected types. TypeScript helps but runtime validation needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[3] - createRoute · invalid-loader-functionerrorWhenLoader function throws during route initializationThrows
Error from loader functionRequired handlingCaller MUST ensure loader function is defined correctly and doesn't throw during initialization. Wrap route definition in try-catch if loader has initialization logic.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - createRoute · invalid-search-schemaerrorWhenSearch validation schema is invalid or malformedThrows
Error indicating invalid schemaRequired handlingCaller MUST ensure validateSearch function is correctly defined and returns valid schema. Test schema validation during development.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[6] - useBlocker · blocker-shouldblock-fn-uncaught-rejectionerrorWhenshouldBlockFn is async and its returned Promise rejects (network call or other async operation fails inside shouldBlockFn)Required handlingCaller MUST wrap shouldBlockFn body in try-catch and resolve to a boolean even on error. Do not let shouldBlockFn reject — catch errors internally and return false (allow navigation) or true (block) as a safe default.costhighin prodsilent failureusers seelost datavisibilitysilentSources[9]
- useBlocker · blocker-external-navigation-bypasswarningWhenMultiple navigation blockers registered and one throws an error before others can runRequired handlingCaller SHOULD ensure only one navigation blocker is active per component to avoid ordering dependencies. Defensive shouldBlockFn implementations should never throw.costmediumin prodsilent failureusers seelost datavisibilitysilentSources[10]
- useAwaited · awaited-deferred-rejection-no-error-boundaryerrorWhenDeferred Promise passed to useAwaited rejects and no error boundary wraps the componentRequired handlingCaller MUST wrap useAwaited/Await usage in either: (1) a route errorComponent defined on the route that passes loader data, (2) a React Suspense + ErrorBoundary pair, or (3) the CatchBoundary component from @tanstack/react-router. Without an error boundary, deferred data loading failures crash the UI.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[11]
- useAwaited · awaited-missing-suspense-boundaryerrorWhenuseAwaited called with a pending deferred promise and no React Suspense boundary in the ancestor treeRequired handlingCaller MUST either: (1) use Await with a fallback prop to auto-wrap in Suspense, (2) wrap useAwaited calls in a React.Suspense boundary, or (3) use within a route that has pendingComponent defined. Every deferred data access point needs a Suspense boundary.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[11]
- lazyRouteComponent · lazy-route-component-import-failureerrorWhenDynamic import fails due to network error, wrong path, or non-ModuleNotFound errorRequired handlingCaller MUST define an errorComponent on the route that uses lazyRouteComponent, or wrap the route in a CatchBoundary. Without an error boundary, import failures permanently crash the route subtree. Additionally, the parent route should define errorComponent to catch lazy load failures during navigation.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
- lazyRouteComponent · lazy-route-component-chunk-hash-mismatch-loopwarningWhenChunk hash mismatch after new deploy: single auto-reload fires but module still not found (CDN cache serving old assets)Required handlingCaller SHOULD implement errorComponent on routes using lazy components to display a user-friendly "Please refresh the page" message when the auto-reload cannot resolve the chunk. This catches the post-reload throw loop.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[12]
- useLoaderDeps · loader-deps-route-mismatch-stricterrorWhenstrict: true (default) and current route does not match the 'from' parameterRequired handlingCaller MUST either: (1) use the correct 'from' route ID matching the current route, (2) set strict: false when using in shared components rendered across multiple routes, or (3) wrap in error boundary. TypeScript strict route types catch most cases at compile time when using file-based routing.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
- RouterProvider · router-provider-loader-initialization-errorerrorWhenRoot route loader or beforeLoad hook throws a non-redirect, non-notFound error during app initializationRequired handlingCaller MUST define errorComponent on the root route or wrap RouterProvider in a top-level React ErrorBoundary to catch initialization failures. Root-level loaders (e.g., auth checks in beforeLoad) that throw will crash the app if no error boundary exists at or above RouterProvider.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
- RouterProvider · router-provider-missing-contexterrorWhenAny TanStack Router hook used outside RouterProvider component tree (context returns null)Required handlingCaller MUST ensure all TanStack Router hooks are used within a component tree that has RouterProvider as an ancestor. For components used in both router and non-router contexts (e.g., Storybook), wrap hook usage in conditional checks or use useRouter({ warn: false }) and check for null before calling methods.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[17]
Sources
Every postcondition cites at least one of these. Grouped by source type; numbered to match the footnotes above.
- [1]tanstack.com/router/latest/docsType Safety
- [3]tanstack.com/router/latest/docsType Safety
- [4]tanstack.com/router/v1/docsNot Found Errors
- [5]tanstack.com/router/latest/docsError Boundaries
- [6]tanstack.com/router/latest/docsRouteOptionsType
- [7]tanstack.com/router/v1/docsRouteOptionsType
- [8]tanstack.com/router/latest/docsRouterOptionsType
- [13]tanstack.com/router/latest/docsLazyRouteComponentFunction
- [14]tanstack.com/router/latest/docsUseLoaderDepsHook
- [16]tanstack.com/router/latest/docsError Handling
- [9]github.com/TanStack/router/blobTanStack/router · useBlocker.tsx
- [10]github.com/TanStack/router/blobTanStack/router · router.ts
- [11]github.com/TanStack/router/blobTanStack/router · awaited.tsx
- [12]github.com/TanStack/router/blobTanStack/router · lazyRouteComponent.tsx
- [15]github.com/TanStack/router/blobTanStack/router · RouterProvider.tsx
- [17]github.com/TanStack/router/blobTanStack/router · useRouter.tsx
- [2]github.com/TanStack/router/issuesTanStack/router issue #1181
Research notes
Curator notes from SOURCES.md captured when the profile was written so you can verify the reasoning, not just the rules.
@tanstack/react-router Nark profile Sources
This document lists all authoritative sources consulted when creating the @tanstack/react-router Nark profile.
Package: @tanstack/react-router Versions Covered: 1.0.0 - 1.x.x Contract Version: 1.0.0 Last Verified: 2026-03-12
Official Documentation
Core Documentation
-
Type Safety Guide: https://tanstack.com/router/latest/docs/framework/react/guide/type-safety
- Documents strict mode behavior and runtime type validation
- Documents when route mismatch errors are thrown
- Documents param type validation at runtime
-
Error Boundaries Guide: https://tanstack.com/router/latest/docs/framework/react/guide/error-boundaries
- Documents how loader errors propagate
- Documents ErrorComponent for route-level error handling
- Documents lazy route loading failure handling
-
Not Found Errors Guide: https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors
- Documents behavior when routes are not found
- Documents Navigate component errors on invalid routes
-
Route Options API: https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType
- Documents loader function error propagation
- Documents validateSearch option behavior
- Documents context and beforeLoad options
-
Router Options API: https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType
- Documents router creation error conditions
- Documents duplicate route path errors
- Documents invalid route hierarchy errors
GitHub Issues (Known Behavioral Edge Cases)
Navigation During Component Unmount
- Issue: https://github.com/TanStack/router/issues/1181
- Summary: Navigation triggered after component unmounts causes errors; requires cleanup or error boundary
- Relevance: Encoded as postcondition
navigation-during-unmountwith severity warning
Navigate Component Infinite Loop
- Issue: https://github.com/TanStack/router/issues/1181
- Summary: Navigate component can cause infinite navigation loops exceeding max depth
- Relevance: Encoded as postcondition
navigate-infinite-loopwith severity error
Testing Against Real Codebases
The following patterns were examined to validate this contract:
Verified error conditions:
- Route mismatch with strict: true — confirmed throws at runtime when
fromparam doesn't match current route - Missing loader — confirmed
useLoaderDatathrows when no loader is defined - Search param validation — confirmed
validateSearcherrors surface as route errors
Known limitations:
- Many error conditions are TypeScript compile-time safety features, not runtime errors
- Some errors only surface with strict: true (default)
Known CVEs and Security Issues
None Currently Documented
As of 2026-03-12, there are no open CVEs related to @tanstack/react-router Nark profiles.
Version History
1.0.0 (2026-03-06)
- Initial contract covering @tanstack/react-router 1.x
- Covers: useNavigate, useMatch, useLoaderData, useParams, useSearch, useRouteContext, createRouter, Navigate, Link, createRoute
- Error states: route mismatch, loader errors, search param validation, invalid route hierarchy
Maintenance Notes
Next Review: 2026-06-12 (3 months)
Review triggers:
- @tanstack/react-router releases a major/minor version
- New GitHub issues document behavioral edge cases
- False positives reported in real codebases
- TypeScript strict mode behavior changes
Questions or Corrections
If you find:
- Incorrect behavioral claims
- Missing error states
- Broken documentation links
- Behavioral changes in newer versions
Please open an issue with label package:@tanstack/react-router.