Supabase Local Development
This guide will help you set up and work with Supabase in your local development environment.Prerequisites
Before getting started, ensure you have the following installed:- Node.js (v18 or later)
- Docker
- Supabase CLI (This can be installed automatically by our setup script)
Quick Setup
The monorepo includes a setup script to quickly get Supabase running locally:- Check for prerequisites
- Configure your environment variables
- Start Supabase locally
- Optionally reset and seed the database
Manual Setup
If you prefer to set up Supabase manually, follow these steps:1
Install the Supabase CLI
2
Configure Environment Variables
Create or update your These are the default keys for local Supabase development.
.env.local file in the root of the repo with these variables:3
Start Supabase
4
Apply Migrations
migrations directory.Accessing Supabase Studio
Once Supabase is running, you can access the Supabase Studio at:- Browsing and editing your database tables
- Managing authentication settings
- Configuring storage buckets
- Testing edge functions
- Running SQL queries
- Viewing logs
Common Tasks
Managing the Database
Viewing and Editing Data
Viewing and Editing Data
You can view and edit data directly in the Supabase Studio:
- Open Supabase Studio at
http://localhost:54323 - Click on “Table Editor” in the sidebar
- Select a table to view or edit its data
Creating a Migration
Creating a Migration
When making schema changes:Alternatively, you can use the schema-first approach:
- Update or create schema files in
/data/schemas/ - Generate a migration from the differences:
Resetting the Database
Resetting the Database
To reset your database to a clean state:This will apply all migrations in sequence to rebuild the database.
Working with Authentication
Creating a User
Creating a User
You can create test users through the Supabase Studio:
- Open Supabase Studio at
http://localhost:54323 - Go to “Authentication” → “Users”
- Click “Add User” and enter the user details
Testing Authentication
Testing Authentication
To test auth flows in your application:
- Create a test user as described above
- Use the user credentials to sign in
- Auth state should persist between page reloads
Working with Storage
Creating a Bucket
Creating a Bucket
Storage buckets can be created through the Supabase Studio:
- Open Supabase Studio at
http://localhost:54323 - Go to “Storage”
- Click “New Bucket” and enter a name
- Configure public/private access as needed
Upload and Manage Files
Upload and Manage Files
You can upload files through the Supabase Studio or via code:
Common Issues and Solutions
Docker Not Running
If you see errors about Docker not running, make sure Docker Desktop is started before running Supabase commands.
Port Conflicts
If Supabase fails to start due to port conflicts, check for other services using ports 54321-54325 and stop them.
Database Reset Errors
If database reset fails, try stopping and restarting Supabase:
supabase stop && supabase startAuth Not Working
If authentication isn’t working, check that your environment variables are correctly set in both the .env.local file and your application.
Best Practices
Use Migrations
Always use migrations for schema changes to keep development and production in sync
Schema First
Define schemas in the
/data/schemas/ directory first, then generate migrationsLocal Only
Never connect to production databases from your local development environment
RLS Policies
Always implement Row Level Security (RLS) policies for tables
Types First
Keep TypeScript models in sync with database schema changes
Test Data Reset
Regularly reset your local database to ensure your migrations work correctly
Next Steps
Now that you have Supabase running locally, you can:- Explore the Database Schema
- Learn about Supabase Integration in our stack
- Read the official Supabase documentation for more advanced topics