Islands and deployment
Choose static or on-demand rendering
Start from static output and add a server adapter when request-time behavior is a real requirement.
8 minute lesson
Astro prerenders routes by default. Their frontmatter runs during the build and the result becomes files that a static host can serve directly. This is a strong default for content that changes only when you deploy.
Choose on-demand rendering when the response must depend on the request: a session cookie, authenticated user, frequently changing inventory, or server endpoint. Install the adapter for your deployment runtime, then opt out on that route:
---
export const prerender = false
const session = Astro.cookies.get("session")
---
<p>{session ? "Signed in" : "Guest"}</p>
The rest of a default static project can remain prerendered. If most routes are dynamic, output: "server" reverses the default; individual pages can still use export const prerender = true.
This choice changes the data lifetime and failure model. A static route can publish only data available during the build, but it needs no server execution per visit. An on-demand route can personalize each response, but it now depends on a compatible runtime, environment variables, latency, and uptime.
Choose per route, not per project slogan. Write down what request-specific input forces each dynamic route to exist.
Lesson completed