Sveltekit Supabase Setup

Sveltekit Supabase Setup

Lean how to setup Supabase in Sveltekit to accessing database, auth or for storage.

svelte logo

Want a Svelte site built? Hire Me.

Sveltekit Supabase Setup

A quick run down on how to setup Supabase in Sveltekit.

It is pretty easy to install it using svelte-add but sometimes it might throw errors.

Create a .env file

Once you initialize Sveltekit, create a .env file at the root the Sveltekit project folder.


Create a supabase initialization script file

Create a file in Sveltekit /src/lib/db.js. Paste the following in it.

import { createClient } from "@supabase/supabase-js";

const supabase = createClient(

export default supabase;

This is it. Now to use supabase, you can use the following

import supabase from "$lib/db";

You will now have access to your supabase account.

Sveltekit Supabase Course

Watch a video here

Find related articles

Let's discuss on Twitter