---
title: "Choose build or request rendering"
description: "Prerender each collection at build time or render it when a reader asks for it, set per collection in one rendering policy."
---

> Documentation Index
> Fetch the complete documentation index at: https://nimbus-docs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Choose build or request rendering

Every collection's pages are prerendered at build time unless you say otherwise. The rendering policy in the Nimbus config switches a collection to render on request instead, which needs a server.

## Pick a mode

| Mode | Pages are rendered | Choose it when |
| --- | --- | --- |
| `"build"` (default) | Once, during `astro build` | The site is static, or builds are fast enough |
| `"request"` | When a reader requests them | Builds are slow, or you want [Markdown at page URLs](/ai/markdown-negotiation) or a [remote MCP server](/ai/remote-mcp) |

The policy covers the routes Nimbus serves collections from, and the Markdown and `llms.txt` routes that serve them. Your own files under `src/pages/` keep their own `prerender` setting.

## Prerequisites

- A host with an Astro server adapter: Cloudflare, Netlify, Node or Vercel

## Steps

1. **Add a server adapter**

   From the project root, install the adapter for your host:

   ```sh
   npx @cloudflare/nimbus-docs add adapter-cloudflare
   yarn nimbus-docs add adapter-cloudflare
   pnpm nimbus-docs add adapter-cloudflare
   bunx @cloudflare/nimbus-docs add adapter-cloudflare
   ```

   Other hosts use `adapter-netlify`, `adapter-node` or `adapter-vercel`. The installer sets `output: "server"` and wires the adapter. On Cloudflare, it also adds `rendering: { default: "request" }` if the config has no policy yet.
2. **Set the policy**

   In `astro.config.ts`, set `rendering` in the Nimbus config. `default` applies to the docs, their versions and API references; `collections` sets a mode by collection name:

   ```ts title="astro.config.ts"
   const nimbusConfig = defineNimbusConfig({
     // …
     rendering: {
       default: "request",
       collections: {
         archive: "build",
       },
     },
   });
   ```

   To keep the site prerendered except for one collection, flip it: `default: "build"` with that collection set to `"request"`.
3. **Build the site**

   ```sh
   npm run build
   ```

   Nimbus renders each route in the mode the policy sets, and warns when a route file says otherwise. Run `nimbus-docs check --fix` to update the files: it sets each route's `prerender` line, keeps `getStaticPaths` on built routes only, and names the collection in a collection route's page helper, such as `getCollectionPage(Astro, "sdk")`. `add adapter-*` and the scaffolder update them for you.

## Verify

A request-rendered page has no HTML file in the build output. For a page at `/guide/`:

```sh
ls dist/client/guide/index.html
```

```text
ls: dist/client/guide/index.html: No such file or directory
```

If the file is there, the page's collection is still set to `"build"`: check the collection name in `rendering.collections`. Then deploy and load the page to confirm the server renders it.

## What stays build output

Request rendering changes when HTML is made, not what's discoverable. The sitemap, the search index, `llms.txt`, and each page's Markdown version are still prepared during the build, so search and agents see every page.

## Rules the build enforces

- Every name in `rendering.collections` must be a registered collection with its own catch-all route. An unknown name fails the build.
- `default` covers `docs`, version collections, API collections, and the site-wide `llms.txt` and `llms-full.txt`; each collection's Markdown and section `llms.txt` routes follow that collection's mode. Without `rendering`, every route Nimbus manages is built ahead of time, whatever its `prerender` line says. Once `rendering` is set, any other page collection with its own catch-all route, such as a `blog`, must be listed in `collections`.
- A built route with a dynamic segment, such as `[...slug].astro`, must export `getStaticPaths`. Astro can't build it otherwise, so the build fails and names the file.
- Generated API references render on request only on Cloudflare, except one with [`bundle: false`](/api-reference/large-apis#many-versions), which also works on Node. On other adapters, keep API collections set to `"build"`. See [Large APIs](/api-reference/large-apis#render-on-request) for large APIs and many versions.

## Next steps

- [Deploy to Cloudflare](/deploy/cloudflare) or [other hosts](/deploy/other-hosts): ship the server.
- [Serve Markdown at page URLs](/ai/markdown-negotiation): a feature request rendering unlocks.
- [Configuration](/reference/configuration#rendering-policy): every `rendering` field.

Source: https://nimbus-docs.com/reference/rendering/index.mdx
