0.0.25 • Published 2 years ago

@svuick/supabase v0.0.25

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
2 years ago

@svuick/supabase

npm (scoped)

Install

Install with npm

npm i @svuick/supabase

Install with pnpm

pnpm i @svuick/supabase

Install with yarn

yarn add @svuick/supabase

Setup

This plugins depends on @svuick/cookie.

src/hooks.ts

import { register } from '@svuick/core/hooks';
import cookie from '@svuick/cookie/hooks';
import supabase from '@svuick/supabase/hooks';

register(cookie);
register(supabase, {
	supabaseUrl: import.meta.env.VITE_SUPABASE_URL,
	supabaseKey: import.meta.env.VITE_SUPABASE_KEY,
	apiPath: '/api/supabase'
});

export { handle, getSession } from '@svuick/core/hooks';

src/routes/__layout.svelte

<script context="module">
	import { register, load, Svuick } from '@svuick/core/app';
	import supabase from '@svuick/supabase/app';

	register(supabase, {
	    supabaseUrl: import.meta.env.VITE_SUPABASE_URL,
		supabaseKey: import.meta.env.VITE_SUPABASE_KEY,
		apiPath: '/api/supabase'
	});

	export { load };
</script>

<Svuick />

The plugin creates a supabase instance scoped to the user in the stuff object and provides the current user and accesstoken in the session. When initialized, the client will automatically sync the session with the server.

Usage

src/routes/index.svelte

<script context="module">
	export const load: Svuick.Load = async ({ stuff, session }) => {
		const { data: profile } = await stuff.supabase
			.from('profile')
			.select()
			.match({ userId: session.user.id })
			.single();

		return {
			props: {
				profile
			}
		};
	};
</script>

<script context="module">
	export let profile;
</script>
import { supabase } from '@svuick/supabase';

// make sure to import from /hooks in api request handlers
// this supabase instance is NOT scoped to the user
import { supabase } from '@svuick/supabase/hooks';

Licence

Licensed under MIT.

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago