The frontend uses Supabase for the payer reminder opt-in flow. The browser hook in src/hooks/useLPSettings.ts writes to the reminder_preferences table, while the server route in app/api/reminders/route.ts reads from reminder_preferences and writes to sent_reminders through the admin client.
The current implementation expects two tables:
| Column | Type | Notes |
|---|---|---|
address |
text |
Primary key; stores the wallet address that opted in to reminders. |
email |
text |
Required email address for reminder delivery. |
enabled |
boolean |
Defaults to true; the unsubscribe flow flips this to false. |
updated_at |
timestamptz |
Defaults to now() and is refreshed on each upsert. |
| Column | Type | Notes |
|---|---|---|
id |
uuid |
Default gen_random_uuid(); primary key. |
invoice_id |
text |
The invoice identifier used to avoid duplicate reminder emails. |
milestone |
int |
Expected values are 24 or 72. |
sent_at |
timestamptz |
Timestamp of the reminder dispatch. |
email |
text |
The address that received the reminder. |
idx_sent_reminders_invoice_milestoneon(invoice_id, milestone)to avoid duplicate sends for the same reminder window.milestoneshould be limited to24or72for the current reminder logic.
- Create a new Supabase project or use a local Supabase instance.
- Set the following environment variables in
.env.local:NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY(only required for reminder cron/server-side writes)
- Apply the SQL in supabase/migrations/001_init_reminders.sql.
- Restart the Next.js dev server so the new env vars are picked up.
The current routes use the Supabase admin client when SUPABASE_SERVICE_ROLE_KEY is present, so they can bypass RLS during server-side reminder processing. The migration included below uses permissive local-development policies so a contributor can test the browser flow quickly. For a production deployment, replace these local policies with stricter rules that only allow the intended user or service role access.
The matching starter migration lives at supabase/migrations/001_init_reminders.sql.