What is Supabase?
Supabase is an open-source Firebase alternative that provides:- PostgreSQL Database - Powerful relational database
- Authentication - User management and auth
- Storage - File uploads and CDN
- Real-time - Database subscriptions
- Edge Functions - Serverless functions
Getting Your Supabase Credentials
Step 1: Create a Supabase Project
- Go to supabase.com
- Sign in or create an account
- Click New Project
- Fill in your project details:
- Project name
- Database password
- Region (choose closest to your users)
Save your database password securely - you’ll need it for direct database access.
Step 2: Get Your API Keys
Once your project is created:- Go to Project Settings (⚙️ icon in sidebar)
- Navigate to API section
- You’ll find:
- Project URL:
https://xxxxx.supabase.co - Anon Key: Public API key (safe to use in client-side code)
- Project URL:
Configuring Supabase in CodeRocket
Adding the Integration
- Go to Account → Integrations
- Click Add Integration on Supabase
- Fill in the form:
- Click Test Connection to verify
- Click Create Integration
What Gets Generated
When you enable Supabase for a project and generate code, CodeRocket automatically creates:1. Supabase Client Configuration
src/lib/supabase.ts
2. TypeScript Types
src/types/database.types.ts
3. React Hooks (for React projects)
src/hooks/usePosts.ts
4. Environment Variables
.env.example
Common Use Cases
Example 1: Simple Blog
Prompt:poststable schema- CRUD API routes
- Post list component
- Post creation form
- Post editing interface
Example 2: Todo App
Prompt:todostable- Task components
- Complete/incomplete toggle
- Date picker for due dates
- Filter by status
Example 3: User Authentication
Prompt:- Auth context and hooks
- Login/signup components
- Protected routes
- Row Level Security policies
Setting Up Your Database Schema
Before generating code, you may want to set up your database schema in Supabase:Option 1: Let the AI Design It
Simply describe what you want:Option 2: Pre-define Your Schema
Create tables manually in Supabase first:- Go to Table Editor in Supabase dashboard
- Click New Table
- Define columns and relationships
- Set up RLS policies
Option 3: Provide Schema in Integration Config
When creating the integration, you can optionally provide your database schema:Providing the schema helps the AI generate more accurate types and queries.
Row Level Security (RLS)
Supabase uses RLS to secure your data. The AI-generated code respects RLS policies.Example RLS Policy
Real-time Subscriptions
The AI can generate real-time features using Supabase subscriptions: Prompt:Storage Integration
For file uploads, Supabase Storage is automatically configured: Prompt:- File upload component
- Storage bucket configuration
- Image preview
- Public URL generation
Best Practices
Use Environment Variables
Use Environment Variables
Never hardcode credentials. The AI generates
.env.example files with all required variables.Implement RLS
Implement RLS
Always enable Row Level Security for user data. The AI respects RLS in generated code.
Handle Errors Gracefully
Handle Errors Gracefully
Generated code includes try-catch blocks and error states. Review and enhance as needed.
Type Everything
Type Everything
Use the generated TypeScript types for better developer experience and fewer bugs.
Test Locally First
Test Locally First
Use a development Supabase project for testing before pointing to production.
Troubleshooting
”Failed to connect to Supabase”
1
Check Project URL
Ensure the URL is in the format:
https://xxxxx.supabase.co2
Verify Anon Key
Copy the key from Supabase dashboard → Settings → API
3
Check Project Status
Make sure your Supabase project is active and not paused
4
Test in Supabase Dashboard
Try running a query in the Supabase SQL Editor to confirm the project is working
”RLS policy prevents access”
If generated code can’t access data:- Check your RLS policies in Supabase
- Ensure the user is authenticated if required
- Verify the policy allows the operation (SELECT, INSERT, etc.)
- Consider temporarily disabling RLS for testing
”TypeScript errors in generated code”
- Make sure to install
@supabase/supabase-js - Run
npm installto ensure dependencies are installed - Check that environment variables are properly set
Migration from Other Databases
If you’re migrating from another database to Supabase:- Export your existing schema
- Import into Supabase using the SQL Editor
- Update your CodeRocket integration
- Regenerate components with the new integration

