2. Supabase setup
- Go to Supabase.com and login or create account.
- Create project
- create table (sql)
- create function get_unique_tracks (sql)
- prevent duplicate records (sql)
- add rls policy
- import sample data
Create Table: hotlaps (SQL)
Change 'hotlaps' to your table name if different.
CREATE TABLE public.hotlaps (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT timezone('utc'::text, now()),
driver_name text NOT NULL,
car_model text NOT NULL,
track text NOT NULL,
best_lap_ms integer NOT NULL,
session_id text UNIQUE,
wetlap text,
best_splits integer[]
);
Create Function: (SQL)
create or replace function get_unique_tracks()
returns table (track text)
language sql
as $$
select distinct track from hotlaps where track is not null;
$$;
Prevent Future Duplicate Records: (SQL)
ALTER TABLE hotlaps
ADD CONSTRAINT unique_session_lap UNIQUE (session_id, best_lap_ms);
Create RLS Policy:
ALTER TABLE public.hotlaps ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Allow Read only for all users"
ON public.hotlaps
FOR SELECT
TO anon, authenticated
USING (true);
3. Vercel Setup
- Go to Vercel.com and log into your account.
- Add New Project
- Setup Command Build
- Set Supabase environment variables
- Connect github repository.
Build Command:
--------------
sed -i 's|__SUPABASE_URL_PLACEHOLDER__|'${NEXT_PUBLIC_SUPABASE_URL:-$VITE_SUPABASE_URL}'|g' index.html && sed -i 's|__SUPABASE_ANON_KEY_PLACEHOLDER__|'${NEXT_PUBLIC_SUPABASE_ANON_KEY:-$VITE_SUPABASE_ANON_KEY}'|g' index.html
Overide output directory with a period. "."
Save.
Root Directory:
---------------
Disable
Include files outside the root directory in the Build Step.
Save.
Environment Variables:
---------------------
Select "Config" option
Key: NEXT_PUBLIC_SUPABASE_URL
value: https://abcexample123.supabase.co
Enable: Production,Preview and Development options.
---------------------
Select "Config" option
key: NEXT_PUBLIC_SUPABASE_ANON_KEY
Value: anonkey
Enable: Production,Preview and Development options.