Skip to main content
Learn how to build a user management system that allows users to sign up, sign in, and manage their profile information including avatar images.

What You’ll Build

A user management system with:
  • Email/password authentication
  • User profile management
  • Avatar image uploads
  • Public profile pages
  • Row Level Security for data protection

Architecture Overview

This application uses:
  • Supabase Auth for user authentication
  • Supabase Database for storing profile data
  • Supabase Storage for avatar images
  • Next.js App Router for the frontend
1

Create a New Project

  1. Go to supabase.com/dashboard
  2. Click New Project
  3. Configure your project:
    • Name: User Management App
    • Database Password: Use a strong password
    • Region: Choose your preferred region
  4. Click Create new project
2

Run the User Management Quickstart

In the SQL Editor:
  1. Navigate to SQL Editor
  2. Find User Management Starter: Sets up a public Profiles table
  3. Click Run
This creates the necessary database schema:
3

Set Up Your Next.js App

Create a new Next.js application:
Install Supabase packages:
Create .env.local:
4

Create Supabase Client Utilities

Create lib/supabase/client.ts for client-side operations:
Create lib/supabase/server.ts for server-side operations:
5

Build the Avatar Component

Create app/account/avatar.tsx:
6

Build the Account Form

Create app/account/account-form.tsx:
7

Create the Account Page

Create app/account/page.tsx:
8

Create the Login Page

Create app/login/page.tsx:
Create app/login/actions.ts:
9

Test Your Application

Run the development server:
Visit http://localhost:3000/login:
  1. Create a new account
  2. Fill in your profile information
  3. Upload an avatar image
  4. Update your profile

Key Concepts

Row Level Security

RLS policies ensure:
  • Anyone can view profiles (select using (true))
  • Users can only update their own profile
  • Profiles are automatically created on signup via trigger

Storage Policies

Storage policies control:
  • Public read access to avatars
  • Authenticated users can upload
  • Users can only update their own avatars

Server vs Client Components

Next.js App Router pattern:
  • Server Components: Fetch user data securely
  • Client Components: Handle interactivity (forms, uploads)

Next Steps

Add Social Auth

Enable Google, GitHub, and other OAuth providers

File Upload Tutorial

Learn advanced storage techniques

Realtime Presence

Show online users in real-time

Example Code

Explore more authentication examples