Supabase Admin Client Bypasses RLS for Backend
Need to perform operations that bypass RLS for server-side actions. Can't use regular client for certain admin operations. RLS blocking necessary backend logic.
Supabase admin client uses service role key which bypasses RLS. Use only in secure backend environment, never expose service role key to client.
Common Causes
- Using admin key on client side (security issue)
- Service role key exposed in version control
- Not understanding difference between anon and admin
- Not needed - should use RLS policies instead
- Admin operations without authentication check
How to Fix It
Use admin client only in backend/Edge Functions:
// Edge Function - safe to use admin key
const adminClient = createClient(URL, SERVICE_KEY);
const { data } = await adminClient
.from('users')
.update({ role: 'admin' })
.eq('id', userId);
// Never expose SERVICE_KEY to browser!Store SERVICE_KEY in environment, never commit to Git.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
When should I use admin client?
Only for server-side operations. Edge Functions, backend API endpoints, cron jobs. Never in React app.
What if I need to bypass RLS?
Usually indicates RLS policy is wrong. Fix policy instead. Admin client should be last resort.