To secure a Bolt.new + Supabase + Vercel stack, you need to: (1) enable Row Level Security on every Supabase table with proper policies for each operation, (2) move API keys to Vercel environment variables and ensure service_role key never reaches client code, (3) add security headers via vercel.json, and (4) verify RLS is working before deploying. This blueprint covers the complete security configuration for the most popular Bolt.new deployment stack.
TL;DR
TL;DR
Bolt.new apps deployed on Vercel with Supabase need three critical security configurations: Row Level Security (RLS) policies on every Supabase table, environment variables for API keys instead of hardcoded values, and security headers in your vercel.json. Missing any of these leaves your app vulnerable.
Why This Bolt.new + Supabase + Vercel Stack Needs Extra Attention
The Bolt.new + Supabase + Vercel combination is one of the most popular vibe coding stacks because Bolt.new generates Supabase-connected apps quickly and Vercel deployment is seamless. However, Bolt.new prioritizes speed over security configuration.
Common security gaps in Bolt.new generated apps:
- Missing RLS policies - Supabase tables are created without row-level security enabled
- Exposed API keys - Supabase URL and anon key hardcoded in client-side code
- No security headers - Vercel deployment lacks CSP and other protective headers
- Service role key exposure - Sometimes the service_role key (which bypasses RLS) is accidentally exposed
Step 1: Configure Supabase Row Level Security
This is the most critical step. Without RLS, anyone with your Supabase URL and anon key can read and modify all data in your database.
Enable RLS on Every Table
In the Supabase dashboard, go to each table and enable RLS:
-- Enable RLS on your tables
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
ALTER TABLE comments ENABLE ROW LEVEL SECURITY;
Create Basic RLS Policies
Here are common policy patterns for Bolt.new apps:
-- Users can only read their own profile
CREATE POLICY "Users can view own profile"
ON profiles FOR SELECT
USING (auth.uid() = user_id);
-- Users can update their own profile
CREATE POLICY "Users can update own profile"
ON profiles FOR UPDATE
USING (auth.uid() = user_id);
-- Anyone can read posts
CREATE POLICY "Posts are viewable by everyone"
ON posts FOR SELECT
USING (true);
-- Only authenticated users can create posts
CREATE POLICY "Authenticated users can create posts"
ON posts FOR INSERT
WITH CHECK (auth.role() = 'authenticated');
-- Users can only update their own posts
CREATE POLICY "Users can update own posts"
ON posts FOR UPDATE
USING (auth.uid() = author_id);
Step 2: Secure Your Supabase API Keys
Bolt.new often generates code with hardcoded Supabase credentials. Move these to environment variables.
What's Safe vs Dangerous
| Key Type | Client-Side Safe? | Why |
|---|---|---|
| SUPABASE_URL | Yes | Public project identifier |
| SUPABASE_ANON_KEY | Yes (with RLS) | Only allows RLS-permitted operations |
| SUPABASE_SERVICE_ROLE_KEY | NEVER | Bypasses all RLS, full database access |
Vercel Environment Variables
Add your Supabase keys to Vercel:
- Go to your Vercel project settings
- Navigate to Environment Variables
- Add
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEY - For server-side only, add
SUPABASE_SERVICE_ROLE_KEY(without NEXT_PUBLIC_ prefix)
import { createClient } from '@supabase/supabase-js';
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
Step 3: Add Security Headers on Vercel
Create or update your vercel.json with security headers:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
},
{
"key": "Permissions-Policy",
"value": "camera=(), microphone=(), geolocation=()"
}
]
}
]
}
Step 4: Verify Your Configuration
Test that your security is properly configured:
Security Verification Checklist
RLS is enabled on all tables in Supabase dashboard
Each table has appropriate SELECT, INSERT, UPDATE, DELETE policies
No hardcoded API keys in your codebase (check .ts, .tsx, .js files)
Environment variables are set in Vercel dashboard
SUPABASE_SERVICE_ROLE_KEY is only used in server-side code
Security headers are present (check with browser dev tools)
.env files are in .gitignore
Alternative Stacks to Consider
**Bolt.new + Next.js + Supabase**
App Router-specific patterns
**Bolt.new + Firebase**
Firebase alternative stack
**Bolt.new + Supabase**
Supabase-only security guide
Common Bolt.new Security Mistakes
Mistake 1: Using Service Role Key Client-Side
Bolt.new sometimes generates code that uses the service_role key. This key bypasses all RLS and gives full database access. Never expose it to the client.
Mistake 2: Forgetting to Enable RLS
Creating policies without enabling RLS on the table does nothing. Always run ALTER TABLE tablename ENABLE ROW LEVEL SECURITY; first.
Mistake 3: Overly Permissive Policies
Policies like USING (true) for INSERT or UPDATE allow anyone to modify data. Be specific about who can do what.
Frequently Asked Questions
Does Bolt.new automatically configure Supabase RLS?
No. Bolt.new creates the database tables and basic structure, but RLS policies are usually not enabled by default. You must manually enable RLS and create policies for each table.
Is the Supabase anon key safe in Bolt.new apps?
The anon key is designed to be public, but only if RLS is properly configured. Without RLS policies, anyone with the anon key can read and modify all data. Always enable RLS before deploying.
Should I use separate Supabase projects for dev and production?
Yes, strongly recommended. Using separate projects prevents accidental data leaks, lets you test RLS changes safely, and gives you isolated environments.
Run a free security scan to identify exposed API keys, missing RLS, and other common vulnerabilities in your Bolt.new project.
Start Free Scan