~/mfjip612
← Back to all notes

Designing resilient frontend boundaries

Practical patterns for keeping your UI stable as your app and team grow.

2 min read# frontend# systems

A frontend boundary is the line between code that decides and code that renders. When that line is blurred, every small change becomes an exercise in archaeology: you follow props through three layers, discover a hidden dependency on a global, and eventually give up and add one more conditional.

The fix is rarely a new abstraction. It is usually a clearer contract.

Reduce competing signals

A component should have one reason to change. If a list item knows about routing, analytics, formatting, and permissions, then a change to any one of those concerns can break the other three. Split the decisions from the rendering:

  • Route and data loading live at the route boundary.
  • Permissions become a boolean passed in, not a lookup performed deep in the tree.
  • Formatting happens once, at the edge of the data layer.

This keeps the rendering layer small enough to test with plain inputs and outputs.

Design the recovery path

Boundaries are not only about the happy path. Decide what happens when data is missing, when a request is slow, and when the user has no permission. A boundary that only handles success will leak failure handling into every child.

A good boundary makes the failure mode as explicit as the success mode.

type NoteView = {
  title: string;
  publishedAt: Date;
};

export function NoteCard({ note }: { note: NoteView }) {
  return <article>{note.title}</article>;
}

The component above cannot fetch, cannot route, and cannot decide whether the note is published. That is the point. Its contract is small enough to reason about, and the surrounding route owns everything that can fail.

Make the boundary visible

Name the layers in the file system. A route that composes a page should not import a database client. A presentational component should not import a router. When the imports are obviously wrong, the boundary is obvious too.

The goal is not purity. The goal is that a new contributor can tell where a decision belongs without reading the whole application.