diff --git a/src/integrations/better-auth/header-user.tsx b/src/integrations/better-auth/header-user.tsx index cb267d3..1f1a359 100644 --- a/src/integrations/better-auth/header-user.tsx +++ b/src/integrations/better-auth/header-user.tsx @@ -153,7 +153,27 @@ const BetterAuthHeader = () => { clearBasket() void authClient.signOut({ fetchOptions: { - onSuccess: () => void router.invalidate(), + onSuccess: () => { + // Cross-fades the now-cleared Orders list out (and + // the empty state in) instead of popping instantly — + // each order card already carries its own + // `view-transition-name` (see OrdersListView), so + // this reuses that for a proper per-card exit. + if ('startViewTransition' in document) { + // Rejects if the browser can't actually run the + // transition right now (e.g. the tab isn't + // visible) — router.invalidate() still runs either + // way, so there's nothing to handle beyond not + // leaving this as an unhandled rejection. + const transition = document.startViewTransition(() => + router.invalidate(), + ) + transition.ready.catch(() => {}) + transition.finished.catch(() => {}) + } else { + void router.invalidate() + } + }, }, }) }}