Connect Supabase with Claude
Your AI needs four values from your Supabase project to build your app's database. You paste them into your app's key file, .env.local, which stays on your computer. Never paste them into the chat. The same steps work in Codex.
Why a file, not the chat
Whatever you type in the chat leaves your computer, and Supabase's own advice is that a secret key should never travel over chat, email or text. Your app reads the file directly, and the AI uses it without reading the keys out. Supabase can also link AI tools to your whole account; we don't, because this file opens only the one project.
Have these ready
- Your Supabase project: Create a Supabase account
- Your database password, from your password manager
Steps
Step 1: Let your AI open the key file
When it's ready for Supabase, it makes a file named
.env.localin your app's folder and opens it for you. Keep it open for the next steps.- Mac
- It opens in TextEdit.
- Windows
- It opens in Notepad.
You should see: Four lines, each a name in capitals followed by
=and nothing yet. Two start withNEXT_PUBLIC, then comeSUPABASE_SECRET_KEY=andSUPABASE_DB_URL=.If it looks different: Nothing opened? Ask your AI:
Please open .env.local for me.Step 2: Open Connect in Supabase
In your Supabase project, click Connect in the bar at the top, then Framework.
You should see: Connect to your project, with a block for Next.js whose first line starts
NEXT_PUBLIC_SUPABASE_URL=.Step 3: Copy the first two lines into your file
Click the copy button on that block. In your file, select the two empty lines that start with
NEXT_PUBLIC, and paste over them.You should see: Both lines with a value after
=. The first ends in.supabase.co, and the second startssb_publishable_.If it looks different: If the block says
ANON_KEYinstead, your project has older keys: open Project Settings, then API Keys, click Create new API keys, and come back.Step 4: Copy the secret key
Click the gear icon for Project Settings, then API Keys. Under Secret keys, click the copy button next to the key named
default: it copies the whole key without showing it. Paste it right afterSUPABASE_SECRET_KEY=, with no space.You should see: The line
SUPABASE_SECRET_KEY=followed by your key, which startssb_secret_.If it looks different: A long key that starts
eyJis the older kind. Use the one that startssb_secret_.Step 5: Copy the database connection
Click Connect again, then Direct. Under Connection Method, choose Session pooler. Copy the connection string and paste it right after
SUPABASE_DB_URL=.You should see: A line that starts
SUPABASE_DB_URL=postgresql://, with[YOUR-PASSWORD]in the middle.If it looks different: Make sure it's the Session pooler string: it works on every home and office network.
Step 6: Put your database password in
In that line, select
[YOUR-PASSWORD], square brackets included, and paste your database password over it.You should see: Your password where
[YOUR-PASSWORD]was, with no brackets left.If it looks different: Lost the password? In Supabase, click Database, then Settings, and Reset password under Reset database password. Paste the new one here.
Step 7: Save the file and close it
- Mac
- Press Command-S, then close the window.
- Windows
- Press Ctrl+S, then close the window.
You should see: The window closes without asking about unsaved changes.
Step 8: Tell your AI it's saved
Type
done. Don't paste the keys into the chat.You should see: Your AI says it's connected, then sets up your app's tables.
If it looks different: If it says a value is missing or doesn't work, open the file again and check each line: the value comes right after
=, with no spaces or quotes.Step 9: Check the tables in Supabase
Once your AI says the tables are ready, click Table Editor in Supabase's left sidebar.
You should see: Your app's tables listed, such as customers or bookings.
If it looks different: A red Unrestricted badge on a table means anyone could read it. Tell your AI which table, and it will lock it down.