-
Create a Supabase account at https://supabase.com
-
Create a new project and copy the following from your project settings > .env:
- Project URL
- Project API anon key
- Project API service_role key (secret key)
-
Go to auth inside supabase, click email and disable the confirmation email step.
-
Seed the database with the following SQL. This will create the users table and a trigger function to automatically create a user entry when a new user signs up via Supabase Auth.
/**
* USERS
* Note: This table contains user data. Users should only be able to view and update their own data.
*/
create table users (
-- UUID from auth.users
id uuid references auth.users not null primary key,
full_name text,
avatar_url text,
-- The customer's billing address, stored in JSON format.
billing_address jsonb,
-- Stores your customer's payment instruments.
payment_method jsonb,
email text
);
alter table users enable row level security;
create policy "Can view own user data." on users for select using (auth.uid() = id);
create policy "Can update own user data." on users for update using (auth.uid() = id);
/**
* This trigger automatically creates a user entry when a new user signs up via Supabase Auth.
*/
create function public.handle_new_user()
returns trigger as $$
begin
insert into public.users (id, full_name, email, avatar_url)
values (new.id, new.raw_user_meta_data->>'full_name', new.email, new.raw_user_meta_data->>'avatar_url');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
-
Clone the repository
-
Go to your project and install dependencies:
npm install
-
You can now run the Next.js local development server:
npm run dev
The starter kit should now be running on localhost:3000.