Context
A route folder may hold a<name>.error.tsx, which React Router 7 uses as the route’s error boundary
(0053). ADR 0305 gave the root boundary to
@stackra/navigation and removed the app’s app.error.tsx, but it did not say how a route, a layout or an app
replaces that default. ADR 0232 still describes a failure bubbling to src/app.error.tsx. The owner decided in the
final structure review of 2026-10-24 that the boundary follows React Router’s own rule, the nearest ancestor wins,
and that the file beside a route is the only place a failure view is declared.
Decision
- The default.
@stackra/navigationprovides the root error boundary, and its UI comes from@stackra/ui(ADR 0305, rule 35). Gen wires it into every app. - The nearest ancestor wins. A failure renders the nearest error boundary above the failing route:
routes/<name>/<name>.error.tsx, beside a route, customises that route and every route nested under it.- A layout’s
<name>.error.tsxcovers every route under that layout. - An
.error.tsxfile directly underroutes/, with no route folder of its own, replaces the app-wide default for every route that has no nearer boundary. An app writes one only when it wants a different default. - With none of these, the default of rule 1 applies.
- No option. A route class has no
errorBoundaryoption. The file beside the route is the declaration, and the decorator test of ADR 0294 applies: the folder and the suffix already say it. - Gen maps each file to the React Router export that ADR 0053 names (
ErrorBoundary). That mapping is unchanged. - No
app.error.tsx. Anapp.error.tsxat the app root is not used. The file of rule 2 directly underroutes/is the only app-level override. This ADR fixes its place, not its file name.
Consequences
- A reader finds the failure view for a route by walking up its folders. No option hides it.
- Apps ship no failure view by default. An app that adds a file under
routes/changes the failure view of every route that has no nearer boundary, so that file is reviewed like a default. - The folder rules of ADR 0053 must allow one
.error.tsxdirectly underroutes/, in addition to route and layout folders. - ADR 0232 still names
src/app.error.tsxas a step of the chain. This ADR replaces that step. ADR 0232 is not amended here.
Enforcement
- planned — STA-338, the
kind-pathcheck: an.error.tsxoutside a route or layout folder, and outside theroutes/root, fails. Anapp.error.tsxat the app root fails. - planned — STA-340, the
folder-kindscheck: theroutes/root file is the one.error.tsxallowed beside route folders. - planned — the
Routeoptions type has noerrorBoundarykey, so an object literal that sets one fails typecheck. It checks onceRouteships. - planned — a gen test: a route with no nearer boundary renders the
@stackra/navigationdefault.
Supersedes and sources
Supersedes: none. Amends: 0053 (the boundary chain), 0294 (the(root) row of decision 14) and
0305 (rule 35). Read with
0232, whose chain step to src/app.error.tsx is stale. Sources: the owner’s
decision in the final structure review of 2026-10-24 (STA-428).