# Server-Side Rendering

Routes with `config.mode` set to `"app"` render on the server. Use them when
middleware, authentication, request data, or mutations must run at request
time.

## Request lifecycle

For a matched app route, Neutron:

1. Runs the configured middleware chain.
2. Runs matching layout and page loaders in parallel.
3. Renders their component tree into the document shell.
4. Streams the response when the selected renderer supports streaming.
5. Hydrates the document and starts the client router in the browser.

The initial response contains rendered HTML; it is not an empty client-side
application shell.

## Enable app mode

```tsx
export const config = { mode: "app" };
```

The mode is declared per route, so static documentation or marketing pages can
live beside authenticated application routes in the same project.

## Cache a rendered response

`cache.maxAge` enables Neutron's route response cache:

```tsx
export const config = {
  mode: "app",
  cache: { maxAge: 60 },
};
```

Use request-specific caching rules carefully for personalized responses. Route
headers can also control downstream browser or CDN caching:

```tsx
export function headers() {
  return { "Cache-Control": "public, max-age=60, s-maxage=3600" };
}
```

See [App Routes](/docs/routing/app-routes) for loaders, actions, and the client
entry.
