Documentation
Understanding API Keys | Supabase Docs
What is the ANON Key?
- The
anon
key is like giving your website visitors a visitor pass to look at some information.
- But this pass only works if you tell the system what they’re allowed to see—this is where RLS (Row-Level Security) comes in.
📖 Story: What Happens Without RLS?
- You own the database.
- If someone has the ANON KEY this tells the application that they’re welcome to read your tables.
- However, we still need to put Row Level Security policies on the sensitive parts of our application. For example, we don’t want people to read other users messages in our database.
If you had RLS, you could set a rule:
“Visitors can only see their own messages”
-
Cursor Chat
In the frontend code, use the NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY to test the connection to the database.