Skip to content

Supabase + Sveltekit Auth #5218

Jan 29, 2022 · 13 comments · 30 replies
Discussion options

You must be logged in to vote

Below my code based on @eikaramba's code, modified toz work with the new breaking updates of sveltekit.

I have not fully tested all corners, but I haven't had any problem so far.

Auth.js

// $lib/auth.js
import { env } from '$utils/env';
import { createClient } from '@supabase/supabase-js';
import { goto } from '$app/navigation';
import * as cookie from 'cookie';

const db = createClient(env.VITE_SUPABASE_URL, env.VITE_SUPABASE_ANON_KEY);

export default db;

export const auth = db.auth;

export const signOut = async () => {
	await auth.signOut();
	await unsetAuthCookie();
	goto('/');
};

export const getCookie = (name, token, extra) => {
	const Blank = { path: '/', expires: new Date(0) };…

Replies: 13 comments 30 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@samuelstroschein
Comment options

@ANorseDude
Comment options

@eikaramba
Comment options

@ANorseDude
Comment options

@silentworks
Comment options

Comment options

You must be logged in to vote
2 replies
@eikaramba
Comment options

@silentworks
Comment options

Comment options

You must be logged in to vote
10 replies
@liamsanft
Comment options

@christopherreay
Comment options

@christopherreay
Comment options

@gbailey4
Comment options

@eikaramba
Comment options

Answer selected by akiarostami
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pilcrowonpaper
Comment options

Comment options

You must be logged in to vote
6 replies
@finnstrand
Comment options

@finnstrand
Comment options

@MrVoshel
Comment options

@akiarostami
Comment options

@MrVoshel
Comment options

Comment options

You must be logged in to vote
1 reply
@wwall3r
Comment options

Comment options

You must be logged in to vote
1 reply
@wwall3r
Comment options

Comment options

You must be logged in to vote
1 reply
@silasabbott
Comment options

Comment options

You must be logged in to vote
1 reply
@kbrgl
Comment options

Comment options

You must be logged in to vote
0 replies
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet