[PR #5630] feat(client): refetch session when browser state changes #14373

Closed
opened 2026-04-13 09:26:37 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5630

State: closed
Merged: Yes


Summary by cubic

Automatically keeps the auth session up to date by refetching on window focus, online status changes, cross-tab updates, and optional polling. This reduces stale user state and keeps sessions consistent across tabs.

  • New Features
    • Added a session refresh manager that refetches on:
      • window focus (visibilitychange)
      • going online/offline
      • cross-tab updates via localStorage (broadcast channel)
      • optional polling (refetchInterval)
    • New client config: sessionOptions
      • refetchInterval (seconds, default 0)
      • refetchOnWindowFocus (default true)
      • refetchWhenOffline (default false)
    • getSessionAtom now initializes the refresh manager and toggles $sessionSignal to refetch; includes proper cleanup
    • Exported broadcast-channel and session-refresh from the client package
**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5630 **State:** closed **Merged:** Yes --- <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Automatically keeps the auth session up to date by refetching on window focus, online status changes, cross-tab updates, and optional polling. This reduces stale user state and keeps sessions consistent across tabs. - **New Features** - Added a session refresh manager that refetches on: - window focus (visibilitychange) - going online/offline - cross-tab updates via localStorage (broadcast channel) - optional polling (refetchInterval) - New client config: sessionOptions - refetchInterval (seconds, default 0) - refetchOnWindowFocus (default true) - refetchWhenOffline (default false) - getSessionAtom now initializes the refresh manager and toggles $sessionSignal to refetch; includes proper cleanup - Exported broadcast-channel and session-refresh from the client package <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:26:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14373