This is is a scaffold/template for your SvelteKit project that uses Supabase as a backend. Supabase is an open-source Backend-as-a-Service, an alternative to Firebase.
This scaffold is made to get you started quickly with your SvelteKit app that uses Supabase as a backend. Stop wasting time setting up authentication pages, profile pages and localization (soon) by using this template!
Create a new Supabase project on https://app.supabase.io
Run these SQL commands to setup the database:
You can run and save these SQL scripts in the SQL editor in your Supabase project.
CREATE TABLE public.profiles (
id uuid REFERENCES auth.users NOT NULL,
first_name varchar(255),
last_name varchar(255),
avatar_url varchar(255),
created_at timestamp(0) with time zone DEFAULT now() NOT NULL,
updated_at timestamp(0) with time zone DEFAULT now() NOT NULL,
primary key (id)
);
insert into storage.buckets (id, name, public)
values ('avatars', 'avatars', true);
create policy "Anyone can upload an avatar."
on storage.objects for insert
with check ( bucket_id = 'avatars' );
ALTER TABLE
public.profiles ENABLE ROW LEVEL SECURITY;
create policy "Public profiles are viewable by every authenticated user." on profiles for
select
using (auth.role() = 'authenticated');
create policy "Users can insert their own profile." on profiles for
insert
with check (auth.uid() = id);
create policy "Users can update own profile." on profiles for
update
using (auth.uid() = id);
begin;
drop publication if exists supabase_realtime;
create publication supabase_realtime;
commit;
alter publication supabase_realtime add table profiles;
http://localhost:3000/passwordreset
to the Additional Redirect URLs (change localhost:3000 with whatever domain you are going to use, localhost is just for dev)Create new project based on this template with degit:
npx degit ThomasMol/sveltekit-supabase-scaffold sveltekit-app
Run
npm install
Setup your .env file
Change the filename of .env.example
to .env
(or create one).
In your Supabase project go to settings > API
, and copy the anon public
key and paste it in the .env
file as the SUPABASE_ANON_KEY
environment variable. Copy your Supabase URL
and paste it in the .env
file as well, as the SUPABASE_URL
environment variable.
npm run dev
(Taken from Sveltejs documentation)
To create a production version of your app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.
Nothing here much. Tailwind config is up to the you.
This scaffold depends on several third party packages:
My website
My Twitter