supabase-auth
Run locally
- Create a supabase account here https://app.supabase.com/
- You need to setup your Supabase Database so it can store your users. Go to
SQL Editor
in your Supabase account and run the following SQL query:
create table
public.users (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
moralis_provider_id character varying null,
metadata json null,
constraint users_pkey primary key (id)
) tablespace pg_default;
alter table "public"."users" enable row level security;
create policy "Individuals can view their own user records."
on users for select
using ( (auth.jwt() ->> 'id')::bigint = id);
If you view your database, you can double-check that the query was executed correctly. You should see a table called users
with the following columns and 1 active RLS policy
at the top.
You should see this if you click on that 1 active RLS policy
. This ensures that only authenticated users can view their data.
- Copy
.env.example
to.env
and fill in the values from your supabase dashboard and add the moralis api key - Open
public/script.js
, and fill in the values (located at the top of the file) from your supabase dashboard - Run
yarn dev
to run the server locally
Now your server is running locally with the following endpoints:
- Client:
localhost:3000
(or any other port you set in.env
) - API:
localhost:3000/api
(or any other port you set in.env
)
Now you can authenticate via MetaMask as long as you have the MetaMask browser extention installed in the browser.