Prerequisites
- Node.js 16+ installed
- Docker installed (for local development)
- Git installed
- A Supabase account (for cloud deployment)
Local Development Setup
1. Install Supabase CLI
2. Initialize Supabase in Your Project
supabase
directory with the following structure:
3. Start Local Supabase Services
- Starts a local PostgreSQL database
- Starts the Supabase API
- Starts the Supabase Auth service
- Starts the Supabase Storage service
- Starts the Supabase Edge Functions service
4. Access Local Services
After starting the services, you’ll see URLs for:- API:
http://localhost:54321
- Studio:
http://localhost:54323
- Database:
postgresql://postgres:postgres@localhost:54322/postgres
5. Configure Environment Variables
Create a.env
file in your project root:
Cloud Deployment
1. Create a Supabase Project
- Go to supabase.com
- Sign in or create an account
- Click “New Project”
- Fill in the project details:
- Name
- Database password
- Region
- Pricing plan
2. Get Project Credentials
After project creation, you’ll get:- Project URL
- API Keys (anon and service_role)
- Database connection strings
3. Update Environment Variables
Update your.env
file with production credentials:
4. Link Local Project to Remote
Database Management
Using Supabase Studio
-
Access Studio:
- Local:
http://localhost:54323
- Cloud:
https://app.supabase.com
- Local:
-
Features available:
- Table editor
- SQL editor
- Database backups
- User management
- API documentation
Database Migrations
- Create a migration:
- Apply migrations:
- Reset database:
Security Best Practices
-
API Keys
- Never commit API keys to version control
- Use environment variables
- Rotate keys regularly
-
Database Security
- Use strong passwords
- Enable SSL connections
- Set up IP allow lists
-
Row Level Security (RLS)
- Enable RLS on tables
- Define appropriate policies
- Test security policies
Monitoring and Maintenance
1. Database Monitoring
- Use Supabase Dashboard for:
- Query performance
- Database size
- Connection pool
- Error rates
2. Regular Maintenance
- Monitor database size
- Check for unused indexes
- Review and optimize queries
- Regular backups
Troubleshooting
Common Issues
-
Connection Problems
-
Migration Issues
-
Performance Issues
- Check query performance in Studio
- Review database indexes
- Monitor connection pool