sveltekit-firebase-ssr icon indicating copy to clipboard operation
sveltekit-firebase-ssr copied to clipboard

Session not immediately set when redirected back to app from the OAuth consent screen

Open inman-sebastian opened this issue 1 year ago • 0 comments
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!

inman-sebastian avatar Mar 21 '24 02:03 inman-sebastian