Open AnalyticsOpen Analytics
Home/Documentation

Supabase setup

Two SQL files: schema-app.sql for the management app (`.env`), and schema-analytics.sqlfor each website's tracking project (your data). You may use two Supabase projects or one — your choice.

1. App Supabase (management — `.env`)

Whoever hosts this Next.js app creates one project for sign-in and the site list on /app.

  1. Create a project at supabase.com.
  2. SQL Editor → run supabase/schema-app.sql.
  3. Settings → API → copy URL, Publishable key, and Secret key into .env.local (see .env.example).
  4. Enable Auth providers (Google, GitHub) if needed.

This database stores no pageviews — only accounts and the projects table (which analytics Supabase URL + key to use per website).

2. Your analytics Supabase (per website)

For each tracked site, create your own Supabase project (or reuse one project for multiple sites).

  1. Create the project.
  2. SQL Editor → run supabase/schema-analytics.sql (copy blocks are also in the Add website dialog).
  3. Realtime: Publications → supabase_realtime → add events.
  4. Copy Project URL + Publishable key into Add website and into tracker.js.

One project for everything (optional)

Run both SQL files on the same Supabase project. The app uses table projects (with site_key); tracking uses only events.

Row Level Security

  • App project: authenticated users manage only their rows in projects.
  • Analytics project: anon insert/select on events (tracker + dashboard reads). site_key must match a row in app projects.

Tables

TableFilePurpose
profiles, projectsschema-app.sqlManagement app (registered websites)
eventsschema-analytics.sqlTracking data (site_key from app)