How to Set Up User Authentication in Minutes with Supabase + Claude. Allow users to sign up with Google, Github, etc.

By (@herz) ·

How to Set Up User Authentication in Minutes with Supabase + Claude. Allow users to sign up with Google, Github, etc.  - image 1 How to Set Up User Authentication in Minutes with Supabase + Claude. Allow users to sign up with Google, Github, etc.  - image 2

One of the first things any app needs is user login. Here's exactly how I set up full authentication for Prompted . Email/password signup, Google OAuth, protected routes, the whole thing. No backend experience needed.

What You're Building:
A complete auth system where users can sign up, log in, log out, and access protected content. Supabase handles all the heavy lifting. Password hashing, session tokens, OAuth flows, you don't have to.

Step 1: Set Up Supabase
Create a free project at supabase.com. Once it's live, grab two things from your project settings under API: your Project URL and your Anon Public Key. These go in your app's .env file:
VITE_SUPABASE_URL=your-project-url
VITE_SUPABASE_ANON_KEY=your-anon-key

Step 2: Create the Supabase Client
Ask Claude: "Create a Supabase client file for a React + Vite app using environment variables."
You'll get something like this:
jsimport { createClient } from '@supabase/supabase-js'

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey)
That's your connection to Supabase. Every auth call goes through this.

Step 3: Email/Password Sign Up & Login
Tell Claude: "Build me a signup and login page using Supabase auth with email and password. Include error handling and redirect after login."
The key functions Supabase gives you:
js// Sign up
const { data, error } = await supabase.auth.signUp({
email: 'user@example.com',
password: 'securepassword'
})

// Log in
const { data, error } = await supabase.auth.signInWithPassword({
email: 'user@example.com',
password: 'securepassword'
})

// Log out
await supabase.auth.signOut()
That's it. Supabase handles the hashing, the sessions, the tokens. You just call the function.

Step 4: Add Google OAuth
This is where it gets cool. Go to your Supabase dashboard → Authentication → Providers → Enable Google. You'll need to create a Google Cloud project and get a Client ID and Client Secret (Claude can walk you through this step by step if you ask).
Once that's configured, the code is one function:
jsconst { data, error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: 'https://yoursite.com/auth/callback'
}
})
Users click "Sign in with Google," get redirected to Google's login, and come back authenticated. Supabase handles the entire OAuth flow.

Step 5: Protect Your Routes
Ask Claude: "Create a protected route component that redirects to login if the user isn't authenticated, using Supabase's onAuthStateChange listener."
The concept is simple — listen for auth state changes and conditionally render:
jsconst { data: { subscription } } = supabase.auth.onAuthStateChange(
(event, session) => {
setUser(session?.user ?? null)
}
)
If there's no user, redirect to login. If there is, show the page. Wrap any route you want locked behind this.

Step 6: Create a User Profile Table
Supabase auth gives you a users table automatically, but you'll want a public profiles table for things like display names, avatars, and bios. Ask Claude: "Write a Supabase migration that creates a profiles table linked to auth.users with auto-creation on signup using a database trigger."
This is the part most tutorials skip. The trigger automatically creates a profile row whenever someone signs up so you never have a user without a profile.

The Debugging Workflow:
When something breaks (and it will), here's the loop:

Check the Supabase dashboard → Authentication → Users to see if the user was actually created

Check the browser console for errors

Copy the error, paste it to Claude with context about what you were trying to do

Get the fix, push to GitHub, Vercel auto-deploys

What I'd Do Differently:
Set up the profiles table and trigger FIRST before building any UI. I had to retrofit this later and it caused headaches with missing profile data. Get the database structure right early.

The whole auth system for Prompted was built in a day using this exact process. The tools do all the hard work; you just need to describe what you want.

Prompt

No prompt, free resources

Comments (4)

  1. Arinzaay · · 1 like

    Its funny i'm currently doing this right now and claude is guiding me. But i just ran out of credit so i'd have to wait 24 hours

13 likes · 4 comments · 5 views

Explore more on Prompted