codex-lv3-may-2025

Supabase Database Setup Guide

Learn how to set up a cloud database for your React applications using Supabase - a free, easy-to-use backend platform.

What is Supabase? An open-source Firebase alternative that provides a PostgreSQL database, authentication, storage, and real-time subscriptions.


Why Use Supabase?


Prerequisites

Before you begin:

Time Required: 15-20 minutes


Step 1: Create Your Supabase Account

Go to supabase.com and create a free account.

Show Me Create Supabase Account

💡 Tip: Use your school or personal email. You’ll need to verify your email address.


Step 2: Create a New Project

After logging in, click “New Project” to start.

Show Me Create New Project

What to enter:


Step 3: Set Up Your Database

Wait for your project to finish setting up (this takes 1-2 minutes). You’ll see a loading screen while Supabase creates your database.

Show Me Database Setup

⚠️ Important: Save your database password! You’ll need it to connect from your app.

What’s happening: Supabase is creating a PostgreSQL database, setting up authentication, and configuring your project.


Step 4: Navigate to the Table Editor

Once your project is ready, click on the Table Editor icon in the left sidebar.

Show Me Table Editor Navigation

What is the Table Editor? A visual interface for creating and managing database tables - think of it like a spreadsheet for your data.


Step 5: Create Your First Table

Click “New Table” to create a table for your data.

Show Me Create Table

What to enter:

💡 Naming Tips:


Step 6: Add Columns to Your Table

Define what information each row will store by adding columns.

Show Me Add Columns

Example for a Todo List App:

Column Name Type Options
id int8 Primary key, auto-increment (created automatically)
created_at timestamptz Default: now() (created automatically)
task text Required
completed bool Default: false
priority text Optional

Common Column Types:

💡 Tip: The id and created_at columns are added automatically - you usually don’t need to change these!


Step 7: Insert Your First Row (Part 1)

Click “Insert”“Insert row” to add data to your table.

Show Me Insert Row - Part 1

Step 8: Enter Row Data (Part 2)

Fill in the values for your new row.

Show Me Insert Row - Part 2

Example for Todo List:

Note: You don’t need to fill in id or created_at - these are auto-generated!

Click “Save” when done.


Step 9: Add More Data

Add at least 3 rows of data to your table. This will help you test your app later!

💡 Practice Tip: Add diverse data to test different scenarios:


Step 10: Set Up Read Policy (Allow Public Read Access)

To let your React app read data, you need to set up security policies.

Click on “RLS” (Row Level Security) or “Policies” tab, then click “New Policy”.

Show Me RLS Policies Button

This opens the policy creation screen where you can configure security rules.

Show Me Policy Creation Screen

Select the first template on the left: “Enable read access for all users”

Show Me Template Selection

This allows anyone to read your data (perfect for demo apps and learning projects).

When to use this:

⚠️ Security Note: For production apps with private data, you’ll want more restrictive policies!


Step 11: Set Up Write Policy (Allow Public Write Access)

To let your React app create new data, add another policy.

Click “New Policy” again.

Show Me Allow Public to Write

Steps:

  1. Give it a policy name (e.g., “Enable insert for all users”)
  2. Select “INSERT” operation
  3. Add true to the “with check” statement in the policy
  4. Click “Save”

This allows anyone to create new rows in your table.

⚠️ Security Warning: Only use this for demo apps and learning! Real apps should authenticate users first.


✅ You’re All Set!

Your Supabase database is now ready to connect to your React app!

What you have:


Next Steps

Connecting to React

You’ll need:

  1. Project URL - Found in Project Settings → API
  2. Anon (public) key - Found in Project Settings → API → Project API keys

Stay tuned for the React integration guide!

Coming Next:


🆘 Troubleshooting

Issue: Can’t see my data in the app

Solution:

Issue: Can’t insert data

Solution:

Issue: Forgot my database password

Solution:


📚 Resources

Official Documentation:

Video Tutorials:


🎯 Quick Reference

Supabase Dashboard Sections:

Common Terms:


Congratulations! You’ve set up your first cloud database. You’re ready to build data-driven applications! 🚀


Attribution: This guide was created with assistance from Claude AI (Anthropic) to provide clear, step-by-step instructions for setting up Supabase.