# Deployment (https://press.fumadocs.dev/docs/deployment)

`fumapress build` writes the site to `dist/`. Deploy to a platform if anything renders on demand, or to a static host if nothing does.

The render mode of a page follows its content source, and one site can have both kinds:

| Content source                                       | Its pages                 |
| ---------------------------------------------------- | ------------------------- |
| Static, like MDX files                               | Prerendered at build time |
| Dynamic, like [Notion](/docs/content-sources/notion) | Rendered on demand        |

Files generated from your content, like `.md` files, the sitemap and Open Graph images, use the render mode of their pages.

## What Needs a Server [#what-needs-a-server]

- A dynamic source, like [Notion](/docs/content-sources/notion) and [Sanity](/docs/content-sources/sanity).
- [AI chat](/docs/plugins/ai#ai-chat) and [MCP](/docs/plugins/ai#mcp).
- The [OpenAPI proxy](/docs/plugins/api-docs#proxy).
- [Feedback](/docs/plugins/feedback) with actions on the server. Actions in the browser don't need a server.
- [Server-side search](/docs/search#server-side-search), when you enable it.
- Custom pages and API routes rendered on demand.

- [Self-hosted image optimization](/docs/content#image-optimization).
- A plugin with `middleware` in `.plugins()`, like [authentication](/docs/authentication). A build without a server warns that the middleware never runs.

The default plugins don't need a server. On a static build, they leave out what needs one, like the Markdown [content negotiation](/docs/plugins/ai#content-negotiation) of llms.txt.

## Render Mode [#render-mode]

The `mode` option of `createPress()` changes when content renders, for every source or by source key:

```tsx title="press.config.tsx"
createPress(
  {
    docs: docsSource,
    guides: notion.dynamicSource({ baseDir: "guides" }),
  },
  { mode: { guides: "force-static" } },
);
```

- `auto`: the default described above.
- `force-dynamic`: render on demand, so that every request reaches middleware, like for [authentication](/docs/authentication).
- `force-static`: load a dynamic source once at build time, and prerender its pages.

### Cache Headers [#cache-headers]

A dynamic source with `staleTime`, in milliseconds, is read again once that time has passed:

```tsx title="press.config.tsx"
createPress({ ...notion.dynamicSource(), staleTime: 60_000 });
```

Its pages rendered on demand, with their `.md` files and Open Graph images, have the same time as `s-maxage` in their `Cache-Control` header, so a CDN keeps them that long. Without `staleTime`, Fumapress sets no `Cache-Control`.

## Platforms [#platforms]

The adapter for Vercel, Netlify or Cloudflare is detected at build time. Other platforms get the Node.js adapter. When nothing [needs a server](#what-needs-a-server), the build has no function, like a Vercel Function, and the platform serves static files.

The platforms serve prerendered pages and the files of `public/` without your function, so middleware only runs for routes rendered on demand. On a Node.js server, it runs for every request.

### Node.js [#nodejs]

```npm
npm run build
npm run start
```

To run the server without the CLI, like in a container:

```bash
PORT=8080 node dist/serve-node.js
```

### Vercel [#vercel]

Import the repository.

### Netlify [#netlify]

Import the repository. The build generates a `netlify.toml`, unless your project has one. Commit it, or copy its settings into yours.

<Callout type="warn">
Keep Pretty URLs off in your own `netlify.toml`, so that pages keep their URLs without a trailing
slash.
</Callout>

### Cloudflare [#cloudflare]

[Workers Builds](https://developers.cloudflare.com/workers/ci-cd/builds/) is detected for you. To deploy from elsewhere, [set the adapter](#building-for-another-platform), build, then run:

```bash
npx wrangler deploy
```

Workers Builds doesn't expose the site URL, so set [`site.baseUrl`](/docs/configuration#url).

The build generates a `wrangler.jsonc`, unless your project has a Wrangler config. In your own config, keep `html_handling: "drop-trailing-slash"`, and set `assets.directory` to `./dist/public` when nothing needs a server.

<Callout type="warn">
Open Graph images rendered on demand can exceed the 10 ms of CPU time per request on the Workers
Free plan.
</Callout>

### Building for Another Platform [#building-for-another-platform]

To build for a platform outside of its own build system, like in your own CI, set `adapter`:

```ts title="vite.config.ts"
press({
  adapter: "waku/adapters/cloudflare",
});
```

## Static Hosts [#static-hosts]

For GitHub Pages, a CDN or any file host, the site must have [nothing that needs a server](#what-needs-a-server).

### Turn Off Image Optimization [step] [#turn-off-image-optimization]

If you installed `sharp`, [turn off image optimization](/docs/content#disabling-optimization).

### Upload the Build [step] [#upload-the-build]

Build, then upload `dist/public`.

The build generates a `404.html`, which most hosts use automatically. With [internationalization](/docs/internationalization), it is in the default language.

## Base Path [#base-path]

For a URL like `https://user.github.io/repo/`, set `basePath` and include the path in `site.baseUrl`. On Cloudflare, this needs Wrangler 4.148 or later.

```ts tab="vite.config.ts"
press({
  basePath: "/repo/",
});
```

```tsx tab="press.config.tsx"
createPress(content).config({
  site: {
    baseUrl: "https://user.github.io/repo",
  },
});
```

## Build Errors [#build-errors]

<Accordions>
<Accordion title="fumapress must run through its own CLI">
The build runs `vite` directly. Use [`fumapress build`](/docs/configuration#cli).
</Accordion>
</Accordions>