-
Notifications
You must be signed in to change notification settings - Fork 9
signOut() logout redirect silently fails #283
Copy link
Copy link
Closed
Description
signOut() with auth.redirects.logout configured doesn't navigate. The navigateTo call resolves but Vue Router drops the navigation because clearSession() triggers reactive updates in the same tick.
Reproduce
git clone --depth 1 --filter=blob:none --sparse https://github.com/onmax/repros.git
cd repros && git sparse-checkout set nuxt-better-auth-signout
cd nuxt-better-auth-signout && pnpm i && BETTER_AUTH_SECRET=test-secret pnpm dev- Sign up → lands on
/dashboard - Click "Sign out"
- Expected: redirect to
/ - Actual: stays on
/dashboard(session clears but no navigation)
This is more visible when reactive subscriptions (realtime queries, watchers) react to the auth state change during the same signOut flow.
Root cause
In signOut(), clearSession() triggers the internal watch(clientSession) watcher which fires synchronously. By the time navigateTo(logoutRedirect) executes, Vue Router has pending reactive updates and drops the navigation.
Suggested fix
// useUserSession.ts signOut()
if (logoutRedirect)
+ await nextTick()
await navigateTo(logoutRedirect)nextTick() lets the reactive cascade from clearSession() settle before navigating.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels