# Publish a deck on Vercel

**Goal:** add a `vercel.json` configuration to a Markdown deck, run and inspect the exact static
build locally, and publish it on Vercel from Git or with the Vercel CLI.

The starting files for this guide live in `examples/deck-starter/` (`slides.md` and `package.json`).
For the full deployment reference — including sites built on `@recit/site`, PDF exports on Vercel,
and custom domains — see [Deploy on Vercel](/documentation/configuration/deploy-vercel).

## 1. Start from the deck

Start in a project folder that holds `slides.md` and `package.json` with `recit` installed, such as
`examples/deck-starter/` (or a folder created by following
[Write and present your first deck](/documentation/guides/first-deck)):

- `slides.md` defines three Markdown slides (`Lorem Ipsum`, `Sed do eiusmod`, and a quotation);
- `package.json` lists `recit` in `dependencies` and defines `"build": "recit build slides.md"`, so
  `recit build slides.md` already compiles the deck locally.

Make sure your package manager lockfile (`pnpm-lock.yaml`) is present at the root of the project so
Vercel installs the exact same dependency tree. This guide uses pnpm; a project created with npm, as
in the first-deck guide, keeps its `package-lock.json` and writes `"installCommand": "npm install"`
and `"buildCommand": "npx recit build slides.md -o dist"` in the next step.

## 2. Add vercel.json at the root

Create `vercel.json` next to `package.json` and `slides.md`:

```json title="vercel.json"
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "framework": null,
  "installCommand": "pnpm install",
  "buildCommand": "pnpm exec recit build slides.md -o dist",
  "outputDirectory": "dist"
}
```

- `"$schema"` points your editor to Vercel's JSON Schema so keys and values are validated as you
  edit.
- `"framework": null` stops Vercel from guessing a framework and overriding the commands in this
  file.
- `"installCommand"` runs `pnpm install` to install `recit` and the project's dependencies before
  building.
- `"buildCommand"` runs the project's `recit` CLI to compile `slides.md` into the `dist` directory
  (`-o, --output <dir>`).
- `"outputDirectory"` tells Vercel to serve the generated `dist` folder as static files.

If you later deploy a full site built on `@recit/site` instead of a standalone deck, set
`"outputDirectory": null` so Vercel reads the build's `.vercel/output` directory (see
[Deploy on Vercel](/documentation/configuration/deploy-vercel)).

## 3. Run the build on your machine

Before deploying, run the exact `buildCommand` from `vercel.json` on your machine:

```bash
pnpm exec recit build slides.md -o dist
```

`recit build` compiles the story in strict mode by default (exiting non-zero on blocking density or
data diagnostics unless `--no-strict` is passed) and writes a self-contained static folder in
`dist/`:

- `dist/index.html` — the entry HTML page of the deck;
- `dist/assets/` — the compiled `main.js` and `main.css` bundles, theme fonts, and any local media
  referenced by the slides.

What `recit build` writes is purely static and needs no Node.js server at runtime. Check `dist/`
locally with any static file server:

```bash
npx serve dist
```

Open the local address in your browser: the first slide (`Lorem Ipsum`) is displayed, `ArrowRight`
moves to slide 2 (`Sed do eiusmod`), and every file under `/assets/` loads without error. Stop the
local server (`Ctrl+C`) once verified.

## 4. Deploy to Vercel

You can publish the deck either by connecting a Git repository or directly from your terminal with
the [Vercel CLI](https://vercel.com/docs/cli).

### Option A: From Git

1. Push the project (`slides.md`, `package.json`, `pnpm-lock.yaml`, and `vercel.json`) to GitHub,
   GitLab, or Bitbucket.
2. Open [vercel.com/new](https://vercel.com/new) and import the repository (in a monorepo, set
   **Root Directory** to the deck's folder).
3. Leave **Framework Preset** on "Other" — Vercel reads the install, build, and output settings from
   `vercel.json`.
4. Click **Deploy**. Pushes to your production branch update the production URL, while other
   branches and pull requests receive preview URLs.

### Option B: With the Vercel CLI

From the deck's folder, sign in and link the project once, then deploy a preview URL first and
publish to production with `--prod`:

```bash
pnpm dlx vercel login
pnpm dlx vercel link
pnpm dlx vercel deploy
pnpm dlx vercel deploy --prod
```

`vercel deploy` (and `vercel deploy --prod`) uploads the project sources and lets Vercel run the
commands in `vercel.json`. To build on your machine and upload that prebuilt output instead, run
`vercel pull --yes`, `vercel build`, and `vercel deploy --prebuilt` (adding
`--environment=production` and `--prod` for production; see
[From your machine](/documentation/configuration/deploy-vercel#from-your-machine)).

Add `.vercel` to `.gitignore` so the local project link and build output are not committed.

## 5. Optional: security headers

A standalone deck is served from `dist/` as plain static files, so its HTTP headers go in a
`headers` array of `vercel.json`, as for any static project on Vercel. The `security` keys of
`recit.config.ts` (`preset`, `headers`, `csp`) belong to the Récit site framework: `recit build`
does not write them for a deck. When you publish decks inside a Récit site (which writes
`.vercel/output` and makes Vercel ignore the `headers` of `vercel.json`), declare them under
`security` instead — see
[Security headers](/documentation/configuration/deploy-vercel#security-headers).

## Check

1. Running `pnpm exec recit build slides.md -o dist` exits with `0` and writes `dist/index.html` and
   `dist/assets/`.
2. Opening the deployed Vercel URL displays the first slide (`Lorem Ipsum`).
3. Pressing `ArrowRight` (`→`) advances to slide 2 (`Sed do eiusmod`), and `ArrowLeft` (`←`) returns
   to slide 1.
4. Requests to `/assets/…` (`main.css`, `main.js`, fonts, and media) load with status `200` and no
   `404` responses.

## See also

- **[Deploy on Vercel](/documentation/configuration/deploy-vercel)** — full reference for
  `vercel.json`, `.vercel/output` on `@recit/site`, security headers, PDF exports on Vercel, and
  custom domains.
- **[Write and present your first deck](/documentation/guides/first-deck)** — create `slides.md`
  from `examples/deck-starter`, preview with `recit dev`, and build `dist/`.
- **[Add a theme and its colors](/documentation/guides/theme-colors)** — apply a named theme or a
  `tokens.json` palette to the deck before publishing.
- **[Exporting](/formats/deck/exporting)** — export the same `slides.md` to a standalone HTML file,
  a PDF, slide images, or PowerPoint.
- **[CLI reference](/documentation/reference/cli)** — options for `recit build`, including
  `-o, --output`, `--base`, and `--no-strict`.
