feat(*): Make the user object available and reactive in any component

This commit is contained in:
Josh Creek
2024-04-10 22:03:37 +01:00
parent 4c9631e00f
commit 7c0dec0cb4
3 changed files with 27 additions and 5 deletions
+9
View File
@@ -1,9 +1,18 @@
<script lang="ts">
import { onDestroy } from 'svelte';
import { user } from '$lib/stores/user.js';
import { type User } from '@supabase/auth-js';
import SignUp from '$lib/components/SignUp.svelte';
export let data;
let { supabase } = data;
$: ({ supabase } = data);
let localUser: User | null;
const unsubscribe = user.subscribe((value) => {
localUser = value;
});
onDestroy(unsubscribe);
</script>
<div class="hero min-h-screen bg-base-200">