First App.
Your learning space A little progress, every day
EXTRA LESSONWhen your app needs online data

Add accounts with Supabase

Supabase can handle sign-in and store each person’s records while Cloudflare still hosts the website.

In Supabase and your AI helper18 min read & do
By the end of this lesson

Create a test account, save a private record and reconnect to it after signing in again.

Before you begin

This is an alternative to the D1 route, not a requirement after it. Have a working local website and Cloudflare deployment first.

Let’s do this

  1. 1
    In Supabase

    Create a free Supabase project

    Sign in, create an organisation on Free if needed, then create a project such as little-garden-test. Choose a nearby region, set a strong database password and save it in your password manager. Wait for the project to be ready. The free plan has project and usage limits, and quiet projects can pause.

    Supabase: plans and free limits (opens a new tab)
  2. 2
    In Supabase and your local editor

    Give the browser only the public settings

    Find the project URL and publishable key in the Connect or API settings. Ask the AI to configure local VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY values in an ignored .env.local file. These specific values are intended for the browser. Never use a secret key, service_role key or database password there.

    Supabase: public and secret keys (opens a new tab)
  3. 3
    In your AI helper

    Create a table and enforce who owns each row

    Ask the AI for reviewed SQL for plants with id, user_id, name and a watering field. Enable row level security and separate rules for reading, creating, editing and deleting only rows owned by the signed-in user. Have it apply the SQL through the Supabase SQL Editor. A hidden button does not protect a database.

    Supabase: row level security (opens a new tab)
  4. 4
    In your AI helper

    Add the account screens

    Use the official React Auth guide. Ask for sign-up, sign-in, sign-out and password reset, then connect the plant list to the signed-in account. Include clear waiting and error messages. Start with sample records and an email you control.

    Supabase: React and login quickstart (opens a new tab)
  5. 5
    In Supabase

    Set the return addresses and test email delivery

    In Authentication, URL Configuration, set the site URL and add your exact local and live callback URLs to the allowed redirects. During private tests, the built-in email service has tight limits and only sends to authorised team addresses. For real users, configure a suitable custom SMTP email provider before launch. Check that provider’s costs and limits.

    Supabase: sending login emails (opens a new tab)
  6. 6
    In Cloudflare

    Configure Cloudflare and publish

    Add the same public VITE_ settings to the appropriate Pages build environment, then rebuild and deploy. Vite puts VITE_ values into downloadable browser code, so they cannot hold secrets. Give preview builds a test project; use the live project only for production. Create and apply the reviewed schema and access rules in each project you use.

    Vite: public environment variables (opens a new tab)
  7. 7
    In your browser

    Check the account from another session

    Sign up, confirm email if required, add a sample plant, sign out, then sign back in from a private window. The plant should still be there. Continue to the next lesson to test two different users before inviting anyone else.

A message for your AI helper

Add Supabase Auth and private plant records to my first website, keeping Cloudflare Pages hosting. Use the official React quickstart and free plan where suitable. Put only the Supabase URL and publishable key in VITE_ variables. Keep secret/service-role keys and database passwords out of browser code and Git. Create reviewed SQL with row level security and ownership checks for every read, insert, update and delete. Add sign-up, sign-in, sign-out and reset flows, configure allowed callback URLs, and explain test-email restrictions and real SMTP setup costs. Use sample data and separate test/live settings. Guide me through the dashboard steps and verify one account can save and reopen a record.

What you should see

A test user can sign in, create a record, sign out and find it again later. Email delivery and two-user access checks are the remaining gates before inviting real users.

If you get stuck

Go at your own pace. There is no test to pass.