sveltekit-firebase-ssr
sveltekit-firebase-ssr copied to clipboard
Session not immediately set when redirected back to app from the OAuth consent screen
trafficstars
Hey there, first off I wanted to say thank you for the great code base. It's been super helpful in a project I'm working on. The only issue that I seem to be running into with the setup that you have is that when redirected back to my website after authenticating with Google, the session is not immediately set, resulting in the page loading the "logged out" view of the website until I refresh the page.
I was able to (kind of) fix it by doing the following:
<!-- routes/+page.svelte -->
<script lang="ts">
import { signInWith, signOut } from '$lib/client/firebase'
export let data
let { userSession } = data
$: ({ userSession } = data)
</script>
{#if userSession}
{userSession.name}
<button on:click={() => signOut()}>Sign Out</button>
{:else}
<button on:click={() => signInWith('google')}>Continue with Google</button>
{/if}
This technically works, however it still causes a massive layout shift when the userSession variable gets updated by the client. Do you have any advice on how to fix this issue? It would be a huge help!
Thank you!