Auth

Use Supabase Auth with Next.js

Learn how to configure Supabase Auth for the Next.js App Router.


1

Create a new Supabase project

Head over to database.new and create a new Supabase project.

Your new database has a table for storing your users. You can see that this table is currently empty by running some SQL in the SQL Editor.

SQL_EDITOR

_10
select * from auth.users;

2

Create a Next.js app

Use the create-next-app command and the with-supabase template, to create a Next.js app pre-configured with:

See GitHub repo

Terminal

_10
npx create-next-app -e with-supabase

3

Declare Supabase Environment Variables

Rename .env.local.example to .env.local and populate with your project's URL and Anon Key.

.env.local

_10
NEXT_PUBLIC_SUPABASE_URL=your-project-url
_10
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

4

Start the app

Start the development server, go to http://localhost:3000 in a browser, and you should see the contents of app/page.tsx.

To sign up a new user, navigate to http://localhost:3000/login, and click Sign Up Now.

Terminal

_10
npm run dev

Learn more