Supabase Setup
Complete guide to setting up Supabase for BlockForge.
Overview
BlockForge uses Supabase for:
- Authentication - User management and authentication
- Database - PostgreSQL database for data storage
- Storage - File storage for images and documents
- Edge Functions - Serverless functions for API endpoints
Step 1: Create Supabase Project
- Go to supabase.com
- Sign up or log in
- Click "New Project"
- Fill in project details:
- Name: BlockForge (or your preferred name)
- Database Password: Choose a strong password
- Region: Select closest region
- Click "Create new project"
- Wait for project to initialize (2-3 minutes)
Step 2: Get API Credentials
In Supabase Dashboard → Settings (⚙️) → API
Copy these values:
- Project URL:
https://xxxxx.supabase.co - anon public key:
eyJhbGc...(long string starting witheyJ) - service_role key: Keep this secret (for server-side only)
- Project URL:
Add to your
.env.local:
bash
VITE_SUPABASE_URL=https://xxxxx.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGc...Step 3: Run Database Schema
- Go to SQL Editor in Supabase dashboard
- Click New query
- Copy contents of
supabase/schema-migration.sql(or relevant schema files) - Paste into editor
- Click Run (or
Cmd/Ctrl + Enter) - Verify: Go to Table Editor → Should see tables like
pages,workspaces,tasks, etc.
Verify Schema
Check that these tables exist:
workspacespagesblockstasksuserscollections
Step 4: Set Up Storage
Create Storage Buckets
Go to Storage in left sidebar
Click New bucket
Create buckets:
public-uploads- Public bucket for images and filesdocuments- For document uploads (optional)avatars- For user avatars (optional)
For each bucket:
- Set name
- Toggle Public bucket ON for public-uploads
- Click Create bucket
Set Storage Policies
- Go to SQL Editor
- Run storage policies script (check
supabase/directory for storage policies SQL) - This enables authenticated users to upload and access files
Example policy:
sql
-- Allow authenticated users to upload
CREATE POLICY "Authenticated users can upload"
ON storage.objects FOR INSERT
TO authenticated
WITH CHECK (bucket_id = 'public-uploads');
-- Allow public read access
CREATE POLICY "Public read access"
ON storage.objects FOR SELECT
TO public
USING (bucket_id = 'public-uploads');Step 5: Configure Authentication
Email/Password (Default)
Email authentication is enabled by default. Configure email templates in:
- Authentication → Email Templates
GitHub OAuth (Optional)
- Go to Authentication → Providers
- Enable GitHub
- Get OAuth credentials from GitHub:
- Go to GitHub Settings → Developer settings → OAuth Apps
- Register new OAuth application
- Set callback URL:
https://xxxxx.supabase.co/auth/v1/callback - Copy Client ID and Client Secret
- Add to Supabase:
- Client ID: Paste from GitHub
- Client Secret: Paste from GitHub
- Save
Other Providers
BlockForge supports other OAuth providers:
- Apple
- Azure
- And more
Configure in Authentication → Providers
Step 6: Set Up Edge Functions (Optional)
If using Edge Functions for AI or other server-side logic:
- Install Supabase CLI:
bash
npm install -g supabase- Link to your project:
bash
supabase link --project-ref your-project-ref- Deploy functions:
bash
cd supabase/functions
supabase functions deploy function-nameStep 7: Configure Row Level Security (RLS)
RLS policies should be included in your schema migration. Verify they exist:
- Go to Table Editor
- Click on a table (e.g.,
pages) - Go to Policies tab
- Verify policies are set up correctly
Example policies:
- Users can only see their own pages
- Users can create pages
- Users can update their own pages
- Users can delete their own pages
Step 8: Test Connection
- Start your development server:
bash
npm run dev- Open browser console
- Check for Supabase connection errors
- Try signing up/logging in
Troubleshooting
Connection Issues
- Verify
VITE_SUPABASE_URLis correct - Check
VITE_SUPABASE_ANON_KEYis correct - Ensure no typos in environment variables
Schema Errors
- Check SQL Editor for error messages
- Verify all required tables exist
- Check foreign key relationships
Storage Issues
- Verify buckets are created
- Check storage policies are applied
- Test file upload in application
Authentication Issues
- Check email templates are configured
- Verify OAuth callbacks are correct
- Check RLS policies allow user operations
Production Checklist
- [ ] Database schema deployed
- [ ] Storage buckets created
- [ ] RLS policies configured
- [ ] Authentication providers set up
- [ ] Edge Functions deployed (if used)
- [ ] Environment variables configured
- [ ] Connection tested