Deployment

Self-Hosting

Capsul is fully open-source and designed to run on your own server. Two deployment modes are supported depending on your infrastructure.

Mode A — Single VPS (recommended)

Run both Next.js and Express on one server. Next.js builds to production and Express handles API calls and serves deployed apps.

# One-time setup
git clone https://github.com/your-org/capsul
cd capsul
cp .env.local.example .env.local   # fill in values
npm install
npm run build
pm2 start ecosystem.config.js

# Express server
cd server
cp .env.example .env   # fill in values
npm install
npm run build
pm2 start ecosystem.config.js

Mode B — Vercel + VPS

Deploy Next.js to Vercel and run Express on a VPS. Set NEXT_PUBLIC_API_URL to your VPS domain and SPLIT_MODE=true.

# Vercel: add all env vars in dashboard, then deploy
vercel deploy --prod

# VPS: just the Express server
cd server && npm run build && pm2 start index.js

Environment variables

VariableDescriptionExample
NEXTAUTH_URLPublic URL of your Next.js sitehttps://capsul.example.com
NEXT_PUBLIC_FIREBASE_*Firebase client config (7 vars)from Firebase console
FIREBASE_ADMIN_*Firebase Admin SDK credentialsservice account JSON fields
ENCRYPTION_KEYAES-256 key for API key encryption64-char hex string
JWT_SECRETHS256 secret for CapsulDB tokenslong random string
CAPSUL_DATA_DIRDirectory for SQLite app databases/data/capsul
NEXT_PUBLIC_API_URLExpress server URL (split mode)https://api.capsul.example.com
NEXT_PUBLIC_APPS_BASE_URLBase URL for deployed app linkshttps://capsul.example.com
SUPER_ADMIN_EMAILSComma-separated admin email addressesadmin@example.com

See .env.local.example and server/.env.example in the repo.

Nginx reverse proxy

server {
  listen 443 ssl;
  server_name capsul.example.com;

  location / {
    proxy_pass http://localhost:3000;   # Next.js
  }

  location /api/ {
    proxy_pass http://localhost:4000;   # Express (split mode)
  }
}

See nginx/capsul.conf in the repo for the full template.

Data directory

App SQLite files are stored under CAPSUL_DATA_DIR. Back them up with:

tar -czf capsul-backup-$(date +%F).tar.gz /data/capsul