- Published on
Supabase Setup
- Authors
- Name
- Shelton Ma
Setup
1. Sign In and Create a Project
- Visit Supabase and create an account.
- Create a new project and take note of your project URL and API keys.
2. Configure API Keys for a Next.js App
Add the following environment variables to your Next.js .env.local
file:
# .local.env
NEXT_PUBLIC_SUPABASE_URL=<your-supabase-url>
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-key>
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>
Database
1. Using the SQL Editor
Utilize Supabase’s quickstarts, such as the Stripe Subscriptions template, to quickly set up a database schema.
2. Table Editor
create tables
- Enable Row Level Security (RLS): Turn this on for granular access control.
- Column Types: Select appropriate types for your data.
- Default Values: Define defaults for certain fields.
- Timestamps: Set up created_at and updated_at columns. Refer to Updating timestamps automatically in Supabase
- Foreign Keys: Establish relationships between tables.
Configuring Policies
Go to Authentication -> Policies and define the following:
- Allow insert operations for authenticated users only.
- Restrict users to viewing only their own data.
- Allow read access for all users, where applicable.