Skip to main content
Uncaught errors and unknown URLs need product UI, not a stack dump. Add two special files at the routes root.

404

src/routes/_404.tsx
_not-found.tsx is an alias for the same slot. This page does not wrap in _layout.tsx, but it still uses src/routes/_document.tsx. Include whatever chrome you need here. Without this file, unmatched routes return plain text Not Found.

Uncaught errors

src/routes/_error.tsx
Also not wrapped in _layout.tsx. It still renders inside _document.tsx. SPA navigations that fail receive JSON { error } instead of this page.

Throwing vs redirecting

HTTPException(401) is correct for /api/*. On a document request it renders _error.tsx with { status: 401 } — not a login redirect.

Default output

If you skip _error.tsx, document requests get <pre>message</pre> and JSON requests get { "error": "message" } with the exception status.