# Deploying to Vercel

> Source: https://agilitycms.com/docs/sveltekit/deploying-to-vercel

Vercel is the fastest path to production for the [SvelteKit starter](https://github.com/agility/sveltekit-starter): the starter ships with `@sveltejs/adapter-auto`, which resolves to the Vercel adapter automatically — zero config.

## 1. Push the repo

Push your copy of the starter to GitHub (or GitLab/Bitbucket).

## 2. Import the project

On [vercel.com](https://vercel.com), **Add New → Project**, import the repo. Vercel detects SvelteKit and sets the build for you (`vite build` via `npm run build`).

## 3. Set the environment variables

The starter reads its config from `$env/static/private`, which is **inlined at build time** — so these must be set in *Project → Settings → Environment Variables* before you build:

| Variable | Value |
| --- | --- |
| `AGILITY_GUID` | Your instance GUID (*Settings → API Keys*) |
| `AGILITY_API_FETCH_KEY` | Fetch (live) API key |
| `AGILITY_API_PREVIEW_KEY` | Preview API key |
| `AGILITY_SITEMAP` | Sitemap/channel reference name (e.g. `website`) |
| `AGILITY_LOCALES` | Locale code (e.g. `en-us`) |

Deploy — the whole sitemap prerenders at build time.

## 4. Rebuild when editors publish

The starter prerenders every page (see [Routing & Sitemaps](/docs/sveltekit/routing-sitemaps)), so published changes appear after a rebuild:

1. In Vercel: *Settings → Git → Deploy Hooks* → create a hook (e.g. “agility-publish”) and copy its URL.
2. In Agility: *Settings → Webhooks* → add a webhook that fires on **publish** events, pointed at the Deploy Hook URL.

Publish → Vercel rebuilds → fresh content, typically in a minute or two.

## Optional: pin the adapter

`adapter-auto` is fine, but you can make the target explicit (and unlock Vercel-specific options like the Node runtime version):

```bash
npm i -D @sveltejs/adapter-vercel@6
```

> The starter uses SvelteKit 2. `@sveltejs/adapter-vercel` 7 and later require SvelteKit 3, so install version 6 until you upgrade the starter to SvelteKit 3.

```js
// svelte.config.js
import adapter from '@sveltejs/adapter-vercel';
export default { kit: { adapter: adapter() } };
```

> **Preview mode note:** the starter's preview toggle (the `previewMode` cookie) is enabled in local dev. Production on Vercel serves **published** content — use `npm run dev` locally (or a dedicated preview deployment with preview keys) for reviewing staged content.

---

Index of every docs page: https://agilitycms.com/docs/llms.txt
