# Migrate from Vercel

> Run the plan first, review warnings, then apply. The source is read, not modified. Keep it until you have tested sign-in, data, uploads, functions and traffic. Arrange a maintenance window for cutover: a dump does not continuously replicate later writes.

Source: https://docs.infaris.com/en/pulseguard/hosting-migrate-vercel

## What it is

Run the plan first, review warnings, then apply. The source is read, not modified. Keep it until you have tested sign-in, data, uploads, functions and traffic. Arrange a maintenance window for cutover: a dump does not continuously replicate later writes.

## Quick start and CLI

```bash
infaris-guard hosting migrate vercel <project> --team <teamId> --site <siteId> --secrets-file .env.migrate --plan
infaris-guard hosting migrate vercel <project> --team <teamId> --site <siteId> --secrets-file .env.migrate --yes
infaris-guard hosting migrate vercel <project> --team <teamId> --site <siteId> --secrets-file .env.migrate --verify
infaris-guard hosting migrate status
```

`--verify` then compares the same pages on Vercel and on the Infaris site: status, redirect, page title, the headers from `vercel.json` and the security headers. Old is the first own domain on Vercel (after the DNS switch: `--old-url https://<project>.vercel.app`), new is the site's Infaris address (`--new-url` to override); `--paths /a,/b` adds pages. On a difference the command exits with code 1: fix it before you move DNS.

## SDK and code

```ts
// Server-side KV after linking the migrated store to your site.
import { Kv } from '@infaris/kv';
const kv = Kv.fromEnv();
console.log(await kv.get('migration-check'));
```

## Target, variables and the plan

Without `--site`, `hosting up` sets the project up: `--platform vercel` or `cloudflare` for the edge, `--server infaris-cloud` (or the id of your own server) for Infaris Cloud; without a flag Hosting chooses. When the Vercel project has a root directory, the migration publishes that folder inside `--dir`. The variables are on the site before the first build, so one build is enough. `NEXT_PUBLIC_*`, `VITE_*` and other public prefixes move as plain variables (they end up in the bundle anyway) and are a build argument on a server. The plan also names regions and `functions` limits from `vercel.json`, `trailingSlash`/`cleanUrls`, and a source larger than 250 MB (or a file over 100 MB): Hosting does not build a Git commit that large. On Vercel, `regions` and `functions` from `vercel.json` keep working; only a region from the project settings has to go into `vercel.json`. Vercel never returns sensitive variables: put `NAME=value` in `--secrets-file` and they are on the site before the first build as well.

## What does not move

Before anything changes, the plan names what the project relies on that has no counterpart on Hosting: `vercel.json` keys other than redirects, headers, rewrites, crons, functions and regions (legacy `routes`, build overrides, `images`), password protection, Vercel Authentication, trusted IPs and the Firewall, skew protection, a Node version other than the generated Dockerfile's, Vercel SDKs (`@vercel/analytics`, `@vercel/edge-config`, `@vercel/functions`) and `VERCEL_*` variables the code reads. With `--yes` the same list is printed before the first change. A gap that would break the result stops the plan: legacy `routes`, Edge Config, a root directory missing from `--dir`, or (on a server) workspace packages, tsconfig or a lockfile outside the root directory. Fix it, or run on deliberately with `--accept-gaps`.

With `--site`, `--verify` also checks the site itself: every variable, redirect, header and cron that should have moved, and whether each domain has its certificate. Only when all of that holds does it say DNS may move; keep the Vercel project until traffic runs on Hosting. Once the own domain points to Hosting, `--verify` compares with `<project>.vercel.app` by itself.

## Secure defaults

Keep source secrets in the ignored `.env.migrate` file, readable only by you. Use the names below, never actual secrets as CLI arguments. Buckets and functions become private unless you explicitly choose `--keep-public`. Table grants are not copied: review target RLS and exposure.

## Limits

Steps: `site,env,domains,rules,cron,kv,blob,database`. Use `--site` for an existing target; otherwise migration runs `hosting up` in `--dir` (current directory by default). Regex, `has`/`missing` and rewrites may need manual work. PostgreSQL/Neon requires PostgreSQL 17 client tools. Migration does not switch DNS automatically.

## FAQ

**Interrupted?** Repeat the command with the same source and options; it resumes from `.infaris/migrate-vercel-<project>.json`. Keep that file. **Result?** Read the matching `.md` report and `.env.diff` file in `.infaris`. **Skip a step?** `--skip` takes a comma-separated list of the steps above. **Roll back?** Keep the source and switch traffic back; there is no general undo for created target resources.

## Source credentials and cutover checks

In `.env.migrate` (placeholders, not working values):

```dotenv
VERCEL_TOKEN=...
```

Compare the detected framework and build settings. Replace Blob with the Storage SDK. Test existing Redis clients against the KV route. Re-enter sensitive or write-only environment values; the source API cannot return them.

1. Compare row and file counts and review all skipped items in the report.
2. Test sign-in, MFA, RLS with two users, uploads and background work.
3. Update SDK URLs and environment values and publish a test version.
4. Stop source writes for final transfer; check differences before switching traffic.
5. Change DNS and callbacks deliberately, verify the live app and retain the source for rollback.
