Vercel
Deploy chmonitor to Vercel — legacy guide for the Next.js v0.2 build; v0.3+ targets Cloudflare Workers or Docker.
Deploy chmonitor to Vercel using the legacy Next.js build. Vercel auto-deploys on every push to main and inlines client env vars at build time.
Legacy guide — Next.js v0.2 only
This guide targets the legacy Next.js build (v0.2 and earlier). The current app (apps/dashboard, TanStack Start, v0.3+) is designed for Cloudflare Workers. If you are running v0.3 or later, use Cloudflare Workers or Docker instead.
Prerequisites
What you need
- A Vercel account
- Node.js 22.x or later (build runtime)
- A reachable ClickHouse endpoint with a monitoring user
Setup
Use the one-click button, or follow the manual steps.
Import the repo
Go to vercel.com/new and import the repository.
Set build settings
Vercel detects Next.js automatically. Confirm the values below.
| Setting | Value |
|---|---|
| Framework preset | Next.js |
| Build command | bun run build (or npm run build) |
| Output directory | .next |
| Install command | bun install |
| Node.js version | 22.x or later |
Set environment variables
In the Vercel dashboard, go to Project → Settings → Environment Variables and add the variables from Configure below.
Deploy
Click Deploy or push to main to trigger an automatic deploy.
Configure
Set environment variables in Vercel dashboard → Project → Settings → Environment Variables.
Client vs server vars on Vercel
On Vercel (Next.js), client-side vars use NEXT_PUBLIC_*. These are inlined at build time. Server-side vars are plain names. This differs from the TanStack app which uses VITE_*. For dual-surface settings you set the canonical CHM_* name once and the client var is derived from it at build time.
| TanStack (current app) | Next.js / Vercel | Purpose |
|---|---|---|
VITE_AUTH_PROVIDER | NEXT_PUBLIC_AUTH_PROVIDER | Auth provider (client) |
VITE_CLERK_PUBLISHABLE_KEY | NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Clerk publishable key (client) |
VITE_TITLE_SHORT | NEXT_PUBLIC_TITLE_SHORT | Branding (client) |
ClickHouse connection
| Variable | Required | Default | Description |
|---|---|---|---|
CLICKHOUSE_HOST | Yes | — | ClickHouse URL(s), comma-separated |
CLICKHOUSE_USER | No | default | Username(s), same count as HOST |
CLICKHOUSE_PASSWORD | No | "" | Password(s), same count as HOST |
CLICKHOUSE_NAME | No | — | Friendly label(s) for host switcher |
For multiple hosts, all four variables must have the same count:
CLICKHOUSE_HOST=https://ch1:8443,https://ch2:8443
CLICKHOUSE_USER=monitoring,monitoring
CLICKHOUSE_PASSWORD=pass1,pass2
CLICKHOUSE_NAME=primary,replicaQuery / pool tuning
| Variable | Default | Description |
|---|---|---|
CLICKHOUSE_MAX_EXECUTION_TIME | 60 | Query timeout in seconds |
CLICKHOUSE_TZ | — | Timezone for queries |
CLICKHOUSE_DATABASE | system | Default database |
CLICKHOUSE_POOL_SIZE | 10 | Connection pool size |
CLICKHOUSE_POOL_TIMEOUT | 300000 | Pool acquire timeout (ms) |
CLICKHOUSE_POOL_CLEANUP_INTERVAL | 60000 | Pool cleanup interval (ms) |
Feature permissions
Add to Vercel env vars:
CHM_DISABLED_FEATURES=peerdb,actions
CHM_AUTH_REQUIRED_FEATURES=agent,settings,mcp
CHM_FEATURE_AGENT_ACCESS=authenticated
CHM_FEATURE_SETTINGS_ENABLED=falseFor a config file, set CHM_CONFIG_FILE to a path readable by the Vercel function runtime and include the file in the repo.
Feature ids: overview, agent, insights, health, queries, tables, metrics, dashboard, security, logs, settings, cluster, operations, actions, mcp, docs, about.
Authentication
Default provider — safe only on a private network.
CHM_AUTH_PROVIDER=noneAdd an API key layer:
CHM_API_KEY_SECRET=a-long-random-secretCHM_AUTH_PROVIDER=clerk
CLERK_SECRET_KEY=sk_live_...
# Client-side (NEXT_PUBLIC_ prefix; inlined at build)
NEXT_PUBLIC_AUTH_PROVIDER=clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_...CHM_AUTH_PROVIDER=proxy
CHM_CF_ACCESS_TEAM_DOMAIN=https://yourteam.cloudflareaccess.com
CHM_CF_ACCESS_AUD=<audience-tag>CHM_AUTH_PROVIDER=proxy
CHM_PROXY_AUTH_HEADER=X-Forwarded-User
CHM_PROXY_AUTH_SECRET=a-long-random-secretPut chmonitor behind a Vercel Edge Middleware or an upstream proxy that sets the header. See Authentication.
AI agent
LLM_API_KEY=sk-...
LLM_API_BASE=https://openrouter.ai/api/v1
LLM_MODEL=openrouter/free
AGENT_API_TOKEN=bearer-token-for-agent-api
AGENT_ENABLE_CONTROL_TOOLS=falseKeep the LLM key server-side
Never use NEXT_PUBLIC_LLM_API_KEY — keep the key server-side only.
Conversation store
The default is browser localStorage — no server config needed. On Vercel (Next.js v0.2), use postgres for server-side persistence. D1 and Durable Object stores are Cloudflare-only.
Postgres is recommended on Vercel:
CONVERSATION_STORE_BACKEND=postgres
DATABASE_URL=postgresql://user:pass@host:5432/dbnameVercel Postgres, Neon, and Supabase all work. Add DATABASE_URL in the Vercel dashboard.
Health alerting
The health sweep endpoint is GET /api/cron/health-sweep. Trigger it from a Vercel Cron Job or an external cron.
In vercel.json:
{
"crons": [
{
"path": "/api/cron/health-sweep",
"schedule": "*/5 * * * *"
}
]
}HEALTH_ALERT_ENABLED=true
HEALTH_ALERT_WEBHOOK_URL=https://hooks.slack.com/services/...
HEALTH_ALERT_MIN_SEVERITY=warning
CRON_SECRET=a-random-secretBranding
NEXT_PUBLIC_TITLE_SHORT=MyCluster
NEXT_PUBLIC_LOGO=/logo.png
NEXT_PUBLIC_MEASUREMENT_ID=G-XXXXXXXXXX
NEXT_PUBLIC_POSTHOG_KEY=phc_...Verify
- Open the assigned Vercel URL — you should land on the overview page.
- To upgrade, push to
main(or merge a PR) and Vercel auto-deploys. For environment variable changes, update them in the dashboard and trigger a redeploy (Deployments → Redeploy).
For breaking changes between major versions, see Migrating to v0.3.
Troubleshooting
Vercel limitations
- No D1 / Durable Objects: Cloudflare-only. Use postgres or clickhouse for conversation store.
- Function timeout: Vercel Hobby plan limits function duration to 10 s. Use Pro or set
CLICKHOUSE_MAX_EXECUTION_TIMEbelow that limit. - Cold starts: Vercel serverless functions have cold starts. Set
CLICKHOUSE_POOL_SIZEappropriately.
Related
Cloudflare Workers
The current v0.3+ deployment target — serverless, global, D1 and Cron support.
Docker
Run the published container anywhere Docker runs.
Authentication
Choose an auth provider: none, API key, Clerk, or trusted proxy.
Migrating to v0.3
Breaking changes between major versions.
Production checklist
Harden and validate before exposing to a team or the internet.
Cloudflare Workers
Deploy chmonitor to Cloudflare Workers for globally distributed, serverless hosting with D1 and Cron Trigger support.
Self-host (Node / standalone)
Run chmonitor on any server using Node.js or Bun — bare VMs, dedicated servers, or any environment where you manage the process directly.