Skip to content

How to refresh user on page load ? #1076

@mrleblanc101

Description

@mrleblanc101

Environment

Operating system macOS 25.2.0
CPU Apple M1 Pro (8 cores)
Node.js version v24.4.1
nuxt/cli version 3.32.0
Package manager pnpm@10.14.0
Nuxt version 4.2.2
Nitro version 2.12.9
Builder vite@7.3.1
Config auth, compatibilityDate, components, css, devtools, fonts, hooks, i18n, modules, runtimeConfig, vite
Modules @nuxt/eslint@1.12.1, @nuxt/fonts@0.12.1, @nuxtjs/i18n@10.2.1, @sidebase/nuxt-auth@1.1.1, @pinia/nuxt@0.11.3, floating-vue/nuxt@5.2.2

Reproduction

.

Describe the bug

I've tried this:

<script setup>
const { getSession, refresh } = useAuth()

// Attempt 1
console.log('1');
await getSession();
console.log('2');

// Attempt 2
await callOnce(async () => {
    console.log('1');
    await getSession();
    console.log('2');
});

// Attempt 3
await useAsyncData(`account-settings-general-${locale.value}`, async () => {
    console.log('1');
    await getSession();
    console.log('2');
    return true;
});
</script>

And also with refresh instead of getSession.
If I do a client side navigation, it works and I see 1, 2 in the browser console.
If I do a hard refresh, I see 1, 2 in the terminal, but page never load and I have a spinner on the tab.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA question about NuxtAuth

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions