1. Courses
  2. AI Engineering
  3. Build and Launch a Site with AI
  4. Stop 4

30 minBeginner

A database and sign-in with Supabase

Mangrove Kitchen shows recipes but can't remember anyone yet. Here you add a Supabase database and e-mail sign-in, so members can save favourite recipes, with every table locked by row-level security.

By the end you can

  • Create a Supabase project and keep its password and keys in the right places
  • Run the agent's SQL migrations in the SQL Editor and check the result
  • Turn on row-level security for every table and read a simple policy
  • Set up e-mail sign-in and test access as two users

The everyday picture

Think of an office building. Visitors get a day pass at reception. It opens the lobby for everyone, and each tenant's office only for that tenant. The manager's master key opens every door, so it never leaves the manager's office.

In Supabase, the publishable key is the day pass, row-level security is the door rules, and the secret key is the master key that ignores them.

Your project, its password and its keys

gives you a PostgreSQL database plus sign-in in one project. Screens are as of 2026; menus move, so look for the named setting.

  1. Sign in at supabase.com with GitHub and click New project.
  2. Name it mangrove-kitchen. Click Generate a password and save it in your password manager right away.
  3. Pick a region close to your visitors, such as Singapore or Mumbai for South Asia.
  4. Choose the free plan and click Create.

Then open Project Settings, then API Keys:

  • Project URL: your database API's address. Not secret.
  • Publishable key (sb_publishable_…): safe in the browser, because your access rules limit it.
  • Secret key (sb_secret_…): skips every access rule. Server only. Older projects call these the anon and service_role keys.

You copy these into .env.local yourself. Never paste a secret key into the agent's chat: chat history is stored. Tell the agent the variable names instead.

Quick check

The agent asks you to paste "the Supabase keys" into the chat so it can set up the project. What do you do?

Browser publishable key Server code secret key request request Supabase API checked RLS policies row by row allowed rows skips RLS: server only Tables recipe, favourite
The publishable key's requests pass through your row-level security policies, so each member gets only the rows they are allowed. The secret key skips the policies, which is why it lives only in server code.

Loading the rest of the lesson…