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.
- Create a project at supabase.com.
- SQL Editor → run
supabase/schema-app.sql. - Settings → API → copy URL, Publishable key, and Secret key into
.env.local(see.env.example). - 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).
- Create the project.
- SQL Editor → run
supabase/schema-analytics.sql(copy blocks are also in the Add website dialog). - Realtime: Publications →
supabase_realtime→ addevents. - 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_keymust match a row in appprojects.
Tables
| Table | File | Purpose |
|---|---|---|
profiles, projects | schema-app.sql | Management app (registered websites) |
events | schema-analytics.sql | Tracking data (site_key from app) |