Skip to content

Instantly share code, notes, and snippets.

@acoyfellow
Last active March 30, 2021 20:42
Show Gist options
  • Save acoyfellow/eb801139a67459c80cc2925988566ca6 to your computer and use it in GitHub Desktop.
Save acoyfellow/eb801139a67459c80cc2925988566ca6 to your computer and use it in GitHub Desktop.
SvelteKit + firebase example in $layout.svelte
<script>
import "./styles.css";
import { session } from "$app/stores";
import { onMount, setContext } from "svelte";
import { writable } from "svelte/store";
let store = writable({});
setContext("store", store);
$: user = $session.user || null;
onMount(async () => {
window.ssrUser = user;
const storeModule = await import("$services/firebaseClient");
store.set(storeModule);
});
</script>
<slot />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment