Backend
Database
Supabase setup, schema, and queries.
Overview
NextBento uses Supabase (PostgreSQL) for the database. Supabase provides:
- PostgreSQL database
- Row Level Security (RLS)
- Realtime subscriptions
Storage is available on the Supabase platform but is not a shipped NextBento product feature yet.
Client Setup
| Usage | Import | Description |
|---|---|---|
| Server | @/lib/supabase/server | Server-side queries, cookies |
| Client | @/lib/supabase/client | Client components |
| Middleware | @/lib/supabase/middleware | Session refresh |
Schema
The schema is defined in Supabase migrations. Run migrations from the Supabase CLI or Dashboard. Typical tables include:
profiles— User profiles +onboarding_completedsubscriptions— Stripe subscription data (owner)team_members— Team membership (admin|member)team_invitations— Pending invites with roleapi_keys— API keys (hashed)activity_logs— Activity history
RLS (Row Level Security)
Enable RLS on all tables. Policies control who can read/write. Never bypass RLS from the client — use service role only in trusted server code.
Best Practices
- Use server-side Supabase client for mutations
- Validate user identity before queries
- Use migrations for schema changes
- See Supabase Setup for setup and schema