Skip to main content
TanStack Router provides robust error handling through error boundaries that catch and display errors from loaders, components, and navigation.

Error components

Define custom error boundaries at route level:

Error component props

Error components receive helpful props:

Root error boundary

Catch errors from all routes:

Throwing errors in loaders

Throw errors during data loading:

Custom error types

Create typed errors for better handling:

Component errors

Error boundaries also catch component errors:

Resetting errors

The reset function retries the failed operation:

Default error component

Use the built-in error component:

Not found errors

Handle 404 errors separately:

Error logging

Log errors to external services:

Best practices

Give users context about what went wrong and how to recover.
Allow users to retry failed operations.
Create custom error classes for better error handling and recovery.
Integrate with error tracking services like Sentry or LogRocket.

Next steps

Data loading

Learn about loader error handling

Route API

Explore error configuration options