svelte-pocketbase-sync
Version:
A reactive wrapper for PocketBase collections and records in SvelteKit, allowing automatic updates and reactivity.
18 lines (17 loc) • 395 B
JavaScript
import PocketBase from 'pocketbase';
/**
* The PocketBase instance.
* @type {PocketBase}
* */
export const pb = new PocketBase(process.env.POCKETBASE_URL);
/**
* The current authenticated user.
* @type {AuthRecord}
**/
export let user = $state({
current: pb.authStore.record,
logout: pb.authStore.clear
});
pb.authStore.onChange(() => {
user.current = pb.authStore.record;
});