Quickstart Deployment

Deploy a production-ready diy-analytics instance in under 3 minutes using Vercel and a managed PostgreSQL database.


Prerequisites

Before you start, you'll need:

  1. A GitHub account to fork or deploy the repository.
  2. A Vercel account to host the Next.js App Router dashboard.
  3. A PostgreSQL 14+ database with connection pooling (Neon, Supabase, Vercel Postgres, or Railway all work).

Deployment guide

1. Provision a PostgreSQL database

We recommend Neon for instant serverless provisioning and built-in connection pooling:

  1. Sign up at Neon and create a new project.
  2. In the Neon dashboard, select Pooled connection (the host contains -pooler).
  3. Copy your connection string:
text
postgres://user:password@ep-xxxx-pooler.us-east-2.aws.neon.tech/neondb?sslmode=require

2. Deploy to Vercel

Fork the repository and start an automated deployment in your Vercel account:

Deploy with Vercel

3. Configure environment variables

During the Vercel deployment wizard, set the following:

VariableRequiredDescriptionExample
DATABASE_URLYesPooled PostgreSQL connection URI with SSLpostgres://user:pass@host:5432/dbname?sslmode=require
NEXT_PUBLIC_SITE_URLYesPublic URL of your analytics app, no trailing slashhttps://analytics.yourdomain.com
CRON_SECRETNoRandom 32+ character string that secures the daily rollup cronrandom_secret_token_abc123
DATABASE_STORAGE_CAP_MBNoSoft storage threshold shown in the UI512

4. Run database migrations

Apply the schema to your PostgreSQL instance:

bash
npm run db:migrate

If you're deploying from the CLI, clone the repo locally, create a .env.local with your DATABASE_URL, and run the command above. It only needs to run once per database.

5. Log in and create your first site

  1. Open your live deployment URL.
  2. Create your workspace owner account on the initial setup screen.
  3. Click + New Site and enter your website's primary domain.

Adding a new website to your workspace

  1. Copy your tracking script tag:
html
<script async defer src="https://analytics.yourdomain.com/api/tracker.js?site-id=YOUR_SITE_ID"></script>
  1. Paste it into the <head> of your website. See Connecting Your Website for framework-specific guides.

What happens behind the scenes

  • Daily rollups. A Vercel Cron job (/api/cron/rollup) runs every day at 03:00 UTC, compressing raw telemetry into daily aggregates and pruning expired historical records.
  • Real-time telemetry. Sessions appear on your dashboard within seconds of a visitor loading your website.

Next steps