Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions docs/router/framework/react/api/router/NotFoundErrorType.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,40 @@ export type NotFoundError = {
data?: any
throw?: boolean
routeId?: string
headers?: HeadersInit
}
```

## NotFoundError properties

The `NotFoundError` object accepts/contains the following properties:

### `global` property (⚠️ deprecated, use `routeId: rootRouteId` instead)

- Type: `boolean`
- Optional - `default: false`
- If true, the not-found error will be handled by the `notFoundComponent` of the root route instead of bubbling up from the route that threw it. This has the same behavior as importing the root route and calling `RootRoute.notFound()`.

### `data` property

- Type: `any`
- Optional
- Custom data that is passed into to `notFoundComponent` when the not-found error is handled

### `global` property
### `throw` property

- Type: `boolean`
- Optional - `default: false`
- If true, the not-found error will be handled by the `notFoundComponent` of the root route instead of bubbling up from the route that threw it. This has the same behavior as importing the root route and calling `RootRoute.notFound()`.
- If provided, will throw the not-found object instead of returning it. This can be useful in places where `throwing` in a function might cause it to have a return type of `never`. In that case, you can use `notFound({ throw: true })` to throw the not-found object instead of returning it.

### `route` property

- Type: `string`
- Optional
- The ID of the route that will attempt to handle the not-found error. If the route does not have a `notFoundComponent`, the error will bubble up to the parent route (and be handled by the root route if necessary). By default, TanStack Router will attempt to handle the not-found error with the route that threw it.

### `throw` property
### `headers` property

- Type: `boolean`
- Optional - `default: false`
- If provided, will throw the not-found object instead of returning it. This can be useful in places where `throwing` in a function might cause it to have a return type of `never`. In that case, you can use `notFound({ throw: true })` to throw the not-found object instead of returning it.
- Type: `HeadersInit`
- Optional
- HTTP headers to be included when the not-found error is handled on the server side.