Skip to content

Deploy to Vercel

Vercel is the easiest way to run Baan in a serverless environment. The file system on Vercel is read-only, so you must use a cloud storage provider (GCS, S3, or R2) and a cloud database (Turso / libSQL). Baan detects the Vercel environment automatically and switches to the right adapters.

  • A Vercel account
  • A cloud storage bucket — one of:
    • Google Cloud Storage (GCS)
    • Amazon S3
    • Cloudflare R2
  • A Turso account (free tier is sufficient) for the cloud database

Push the Baan repository to your GitHub account:

Terminal window
git remote add origin https://github.com/your-username/your-repo
git push -u origin main
  1. Go to vercel.com/new and click Import Git Repository
  2. Select your Baan repository
  3. Leave the build settings at their defaults — Vercel detects Next.js automatically

On Vercel you do not create a .env file. Environment variables are entered through the project dashboard, where Vercel encrypts them at rest and injects them into every build and runtime invocation.

  1. Go to Project → Settings → Environment Variables (see the Vercel docs for the full reference)
  2. Click Add New to open the Add Environment Variable dialog shown below
Vercel — Add Environment Variable dialog with Key, Value, Environments selector, and Sensitive toggle
The Add Environment Variable dialog in the Vercel project dashboard.
  1. Enter each variable below as Key + Value. The dialog also accepts pasting .env-formatted text into the Key field, or uploading a .env file via Import .env — Vercel parses each line into a separate variable
  2. Set Environments to Production and Preview (Baan needs the same configuration in both), and turn Sensitive on for credentials
  3. Click Save. Repeat for each variable
  4. After all variables are added, redeploy (Vercel does not pick up new variables on the running deployment automatically)

Storage credentials (required — choose one provider)

Section titled “Storage credentials (required — choose one provider)”

The storage provider type is selected during the setup wizard (Step 4) and saved to the database. You only need the credentials here.

Add the keys for the provider you chose:

Google Cloud Storage:

KeyValue
GOOGLE_CLOUD_PROJECT_IDyour GCP project ID
GCS_BUCKET_NAMEthe bucket name
GOOGLE_CLOUD_CREDENTIALS_BASE64base64-encoded service account JSON

Amazon S3:

KeyValue
AWS_REGIONe.g. ap-northeast-1
AWS_S3_BUCKET_NAMEthe bucket name
AWS_ACCESS_KEY_IDIAM access key with the custom S3 policy
AWS_SECRET_ACCESS_KEYcorresponding secret key

Cloudflare R2:

KeyValue
CF_ACCOUNT_IDyour Cloudflare account ID
CF_R2_BUCKET_NAMEthe bucket name
CF_R2_ACCESS_KEY_IDR2 API token key ID
CF_R2_SECRET_ACCESS_KEYR2 API token secret
KeyValue
DATABASE_URLlibsql://your-db-name.turso.io
DATABASE_AUTH_TOKENyour Turso auth token

To get these values: create a database on turso.tech, then run turso db show your-db-name and turso db tokens create your-db-name.

Click Deploy in Vercel. The first deployment will take 2–3 minutes.

Once deployed, open your Vercel URL and navigate to:

https://your-app.vercel.app/baan-admin/setup

The 4-step wizard will:

  1. Detect the Serverless environment automatically
  2. Ask you to create an admin username and password
  3. Ask you to confirm your storage provider
  4. Write the admin secret path and user account directly to your Turso database, then redirect you to the login page

No additional environment variables are required after setup — the admin path and user accounts live in the database, not in Vercel env vars.

Navigate to your secret admin URL:

https://your-app.vercel.app/baan-admin/[your-secret-path]/login

If you have been running Baan locally (with data/app.db) and want to move to Vercel, you need to copy your existing data to Turso before deploying.

TableMigratedReason
usersYesAdmin accounts
settingsYesAll site configuration
refresh_tokensNoSession tokens — users log in again after migration
session_secretsNoAuto-generated on first request

1. Create a Turso database

Terminal window
turso db create your-db-name
turso db show your-db-name --url # copy DATABASE_URL
turso db tokens create your-db-name # copy DATABASE_AUTH_TOKEN

2. Run the migration script

From your local Baan directory:

Terminal window
DATABASE_URL=libsql://your-db-name.turso.io \
DATABASE_AUTH_TOKEN=your-token \
npx tsx scripts/migrate-to-turso.ts

Add --dry-run to preview what will be migrated without writing anything:

Terminal window
DATABASE_URL=libsql://your-db-name.turso.io \
DATABASE_AUTH_TOKEN=your-token \
npx tsx scripts/migrate-to-turso.ts --dry-run

To migrate from a non-default SQLite file, use --source:

Terminal window
npx tsx scripts/migrate-to-turso.ts --source file:data/my-backup.db

3. Add the environment variables to Vercel

DATABASE_URL=libsql://your-db-name.turso.io
DATABASE_AUTH_TOKEN=your-token

4. Deploy

Push to your connected branch or trigger a redeploy in the Vercel dashboard. The migration is idempotent — running it multiple times is safe.

Push a new commit to your connected branch — Vercel deploys automatically. Database migrations run on the first request after deployment.

BehaviorSelf-hostedVercel
StorageLocal or cloudCloud only (GCS / S3 / R2)
DatabaseSQLite file (data/app.db)Turso libSQL (cloud)
Session secretStored in SQLite (session_secrets)Stored in Turso/libSQL (session_secrets)
User managementAdmin panel, stored in SQLite (users)Admin panel, stored in Turso/libSQL (users)
Refresh tokensStored in SQLite (refresh_tokens)Stored in Turso/libSQL (refresh_tokens)
File system writesAllowedRead-only

Baan detects the Vercel environment via the VERCEL environment variable (automatically set by Vercel) and uses serverless-compatible behavior. Storage and database adapters still depend on the provider and credentials configured during setup.