Astro

output: server

output: server is the Astro setting that renders every route on demand unless a route opts out. It needs an adapter.

How it is measured

Set output to server in the config and add an adapter. Pages run per request, with access to cookies, headers, and a database. Add export const prerender = true to a route that should be built ahead.

Check which routes are static by reading the build log, which lists prerendered pages. Anything not listed runs on each request.

Worked example

A booking site for a pottery studio has 4 marketing pages and 6 account pages. In server mode, the 4 marketing pages add prerender = true. The other 6 render per request using the logged-in user.

The team forgets one pricing page. It hits the database on every view until a log shows 30,000 needless queries in a week.

How it differs

output: server defaults routes to on-demand. output: static defaults them to built files. Server excludes the free caching of files; static excludes per-request data unless a route opts out.

Common errors

Choosing server mode for a content site with no dynamic data. Forgetting to prerender marketing pages. Using it without an adapter. Setting cookies on pages that should be cached. Expecting getStaticPaths to run for on-demand routes.

In practice

Start static. Switch only when a route truly needs request data. In server mode, list the prerendered routes and keep that list reviewed.

See also

output: static, Server-side rendering

Sources

Count this on a real site.

Watch my website