Deploy an AI website to Vercel: import, set the variables, migrate first
To deploy an AI website to Vercel from Anticode, export the project as Next.js (or push it to GitHub), import the repository on Vercel, add the variables from .env.example, and override the build command to npm run db:deploy && npm run build so the database migrations run before each build. It's an ordinary Next.js app with Postgres, so Vercel treats it like any other.
Before you start
Guides that answer "deploy AI website to Vercel" often stop at the import screen. This export has a database and staff accounts, so three extra things matter: migrations, the first owner, and keeping previews away from production data.
- The code in a Git repository. The quickest route is Anticode's GitHub push from the project's Settings, which commits the Next.js export to a repository you pick. Downloading the zip and pushing it yourself works too.
- A Postgres database with a connection string. The export's README suggests Neon or Supabase; any Postgres you can reach from Vercel will do.
- A Resend API key if the site should send email. In production the app refuses to send without one, so booking confirmations and sign-in links would fail.
Import and configure the project
- In Vercel, choose New Project and pick the repository. Vercel's Git deployment guide shows the screen; it should detect Next.js as the framework preset.
- Before the first deploy, open the build settings and turn on Override for the Build Command. Enter
npm run db:deploy && npm run build. The export'sbuildscript already runsprisma generatebeforenext build;db:deployisprisma migrate deploy, which applies the tables and the row-level security policies. - Add the environment variables (the table below). They can also be added later under the project's settings, but Vercel only applies changes to new deployments, so redeploy after editing them.
- Deploy. The first build creates the tables, then builds the site.
| Variable | What to put in it |
|---|---|
DATABASE_URL | Your Postgres connection string |
APP_URL | The public address, such as https://www.yourbusiness.com. Used for email links and the same-origin check |
ENCRYPTION_KEY | 32 random bytes in base64 (the file shows a one-line command to make one). Encrypts two-factor secrets |
RESEND_API_KEY, EMAIL_FROM | Your Resend key and the sender, on a domain you've verified with Resend |
NOTIFY_EMAIL | Where booking and message alerts go |
SLOT_CAPACITY | How many bookings one time slot holds (1 by default) |
Mark the key and the connection string as secret values in Vercel, which its environment variables documentation says become write-only after saving. OWNER_EMAIL and OWNER_PASSWORD don't need to be on Vercel at all; see the next step.
Create the first owner
Vercel builds and serves the app, but it doesn't run the seed script. Run it once from your own machine against the production database: put the production DATABASE_URL, OWNER_EMAIL and an OWNER_PASSWORD of at least 12 characters in a local .env, then run npm run db:seed. Delete the password from the file afterwards. Visit /admin/login on the live site, sign in, and set up two-factor sign-in with an authenticator app, which owners and admins must do before they see any data.
Previews and the production database
Vercel deploys every branch push as a preview. With the build command above, a preview build also runs migrations, against whatever DATABASE_URL it's given. Prisma's Vercel deployment guide warns about exactly this: by default the same variable is used for production and previews, so a migration on a branch can change production. Give the Preview environment its own database URL. Prisma's guide also recommends connection pooling for serverless functions, so check whether your Postgres provider gives you a pooled connection string and use it for the app.
Connecting your domain
Add the domain in Vercel's project settings and follow its DNS instructions, then set APP_URL to that exact address and redeploy. If your site was previously on Anticode with the same domain, remove it in Anticode's Domains section first, so the DNS record stops pointing at Anticode.
What doesn't come with you
- Anticode's hosted extras stay behind: connectors, the visual editor, analytics, CMS editing in the dashboard, the security report and automatic backups.
- Edits don't flow back. Changing the code doesn't change the Anticode project; pushing again from Anticode updates the generated files and keeps your other files.
- Database cost and backups are yours, at your Postgres provider.
- Dynamic rendering. The per-request CSP nonce means pages are rendered on each request, not served as static files.
Troubleshooting
- Forms answer "This request didn't come from this site"
APP_URLdoesn't match the address in the browser, for examplewwwagainst the bare domain. Fix it and redeploy.- The build fails at
db:deploy DATABASE_URLis missing for that environment, or the database refuses connections from outside. Check the variable's environment and the provider's network settings.- Sign-in emails never arrive
RESEND_API_KEYorEMAIL_FROMis missing, or the sender's domain isn't verified with Resend.- Everyone's two-factor stopped working
ENCRYPTION_KEYchanged. Rotating it resets two-factor set-up for all staff.
For what's inside the project, see the Next.js template with admin and 2FA. The GitHub integration explains the push, and moving a prototype to production covers the checks around a launch.
Questions people ask
Can I deploy the single-file HTML export to Vercel instead?
Yes, as a static site with no build step, but its forms post to paths that only exist on Anticode, so they won't work there. The Next.js export is the one with working forms.
Why run migrations in the build command?
So the database schema and its row-level security policies are in place before the new code that relies on them goes live. That's the order the export's README gives.
Do I need a paid Vercel plan?
That depends on Vercel's plans and your use, so check Vercel's own terms. Anticode doesn't require one.
Does Anticode deploy to Vercel for me?
No. Anticode pushes the code to GitHub; importing it on Vercel is yours to do, and Anticode never holds Vercel credentials.
Sources
- Vercel Docs: Deploying Git repositories, checked
- Vercel Docs: Configuring a build, checked
- Vercel Docs: Environment variables, checked
- Prisma Docs: Deploy to Vercel, checked