What is the Supabase service_role key and where can I use it?
A key is a long password your app uses to prove who it is to another service. The service_role key, now called the secret key, maps to a Postgres role that has the BYPASSRLS attribute. In plain words, it goes around the database's own access rules, which decide who may see a record (Row Level Security). Supabase's documentation says it has full access to project data and should be used only in backend code you control, such as servers and Edge Functions. That is the part of your app that runs on the service's computers, where visitors cannot look.
Never put it in source code, client bundles (the code every visitor downloads), URLs or chat messages, and do not give its variable a NEXT_PUBLIC_ prefix. If it leaks, replace it (make a new one and turn the old one off) as soon as you fix the cause, and use a separate secret key per backend component so one leak means one replacement.
Sources
- Supabase documentation, API keys, accessed 2026-11-16
- Supabase documentation, Row Level Security, accessed 2026-11-16