What You’ll Build
A todo app with the following features:- User authentication (sign up/login)
- Create, read, update, and delete todos
- Mark todos as complete
- Row Level Security (RLS) to protect user data
- Real-time updates
Prerequisites
Before you begin, make sure you have:- A Supabase account (sign up here)
- Node.js 16+ installed
- Basic knowledge of React and JavaScript
Create a Supabase Project
- Go to supabase.com/dashboard
- Click New Project
- Fill in your project details:
- Name: Todo App
- Database Password: Choose a strong password
- Region: Select the closest region to your users
- Click Create new project
Set Up the Database
In the SQL Editor, run the “Todo List” quickstart:
- Navigate to SQL Editor in the sidebar
- Scroll down and select TODO LIST: Build a basic todo list with Row Level Security
- Click Run to execute the SQL
todos table with the following schema:Get Your API Keys
- Go to Project Settings (the cog icon)
- Click on API
- Find your
URLandanonpublic key - Save these for the next step
Configure Environment Variables
Create a Replace
.env.local file in your project root:your-project-url and your-anon-key with the values from Step 3.Run Your App
Understanding Row Level Security
Row Level Security (RLS) ensures users can only access their own todos. The policies we created automatically filter queries based on the authenticated user’s ID. When a user is logged in:auth.uid()returns their user ID- Policies check if
auth.uid() = user_id - Only matching rows are returned
Next Steps
Add Real-time Updates
Subscribe to database changes for instant updates
User Management
Build user profiles and avatar uploads
Deploy to Vercel
Deploy your app to production
Example Code
Explore more database examples
Troubleshooting
Todos not showing up
Todos not showing up
Check that:
- You’re logged in
- RLS policies are enabled
- The
user_idmatchesauth.uid()
Authentication errors
Authentication errors
Verify:
- Environment variables are set correctly
- Email confirmation is disabled in Auth settings (for testing)
- Check the browser console for detailed errors
CORS errors
CORS errors
Make sure your Supabase URL is correct and matches the project URL exactly.
