[PR #5691] [MERGED] refactor(client): revalidate logic #6162

Closed
opened 2026-03-13 12:49:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5691
Author: @himself65
Created: 10/31/2025
Status: Merged
Merged: 11/18/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/10/30/revalidate


📝 Commits (4)

📊 Changes

13 files changed (+1256 additions, -1300 deletions)

View changed files

📝 demo/expo/.gitignore (+2 -1)
📝 packages/better-auth/src/client/broadcast-channel.ts (+64 -24)
packages/better-auth/src/client/focus-manager.ts (+61 -0)
📝 packages/better-auth/src/client/index.ts (+10 -0)
packages/better-auth/src/client/online-manager.ts (+55 -0)
📝 packages/better-auth/src/client/session-atom.ts (+12 -14)
📝 packages/better-auth/src/client/session-refresh.ts (+31 -62)
📝 packages/expo/package.json (+5 -0)
📝 packages/expo/src/client.ts (+10 -0)
packages/expo/src/focus-manager.ts (+40 -0)
packages/expo/src/online-manager.ts (+45 -0)
📝 packages/expo/test/expo.test.ts (+4 -0)
📝 pnpm-lock.yaml (+917 -1199)

📄 Description

Summary by cubic

Refactored session revalidation to use centralized FocusManager, OnlineManager, and a global BroadcastChannel for consistent refresh across web and Expo/React Native. Replaced direct event listeners with manager-based focus/online detection and a single storage channel.

  • Refactors
    • Added FocusManager and OnlineManager to trigger refetch on focus/visibility and when coming back online.
    • Rewrote session-refresh to use and initialize these managers, replacing direct event listeners.
    • Centralized BroadcastChannel with a global instance and setup; session-refresh now subscribes to it.
    • Simplified session-atom mount logic; managers handle no-op in non-browser contexts.
    • Exported FocusManager and OnlineManager types and symbols from the client entry.
    • Added Expo implementations; expo client auto-sets them up on native, uses expo-network when available, and re-exports.

Written for commit ed6dde1dc7. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5691 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/31/2025 **Status:** ✅ Merged **Merged:** 11/18/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/10/30/revalidate` --- ### 📝 Commits (4) - [`37574ce`](https://github.com/better-auth/better-auth/commit/37574cea79d5b1441ab3e79f3faeaf8ea664298b) refactor(client): revalidate logic - [`0fe561b`](https://github.com/better-auth/better-auth/commit/0fe561b7577a2ff46d4ca078b4793097f1c403b3) fix: lint - [`1bc75e8`](https://github.com/better-auth/better-auth/commit/1bc75e82e712d0fb4d98f19fe66cde9ada364e8f) fix: mock - [`ed6dde1`](https://github.com/better-auth/better-auth/commit/ed6dde1dc70b8d485e866b7fb4ce0d3d8bc4f1be) fix: lint ### 📊 Changes **13 files changed** (+1256 additions, -1300 deletions) <details> <summary>View changed files</summary> 📝 `demo/expo/.gitignore` (+2 -1) 📝 `packages/better-auth/src/client/broadcast-channel.ts` (+64 -24) ➕ `packages/better-auth/src/client/focus-manager.ts` (+61 -0) 📝 `packages/better-auth/src/client/index.ts` (+10 -0) ➕ `packages/better-auth/src/client/online-manager.ts` (+55 -0) 📝 `packages/better-auth/src/client/session-atom.ts` (+12 -14) 📝 `packages/better-auth/src/client/session-refresh.ts` (+31 -62) 📝 `packages/expo/package.json` (+5 -0) 📝 `packages/expo/src/client.ts` (+10 -0) ➕ `packages/expo/src/focus-manager.ts` (+40 -0) ➕ `packages/expo/src/online-manager.ts` (+45 -0) 📝 `packages/expo/test/expo.test.ts` (+4 -0) 📝 `pnpm-lock.yaml` (+917 -1199) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Refactored session revalidation to use centralized FocusManager, OnlineManager, and a global BroadcastChannel for consistent refresh across web and Expo/React Native. Replaced direct event listeners with manager-based focus/online detection and a single storage channel. - **Refactors** - Added FocusManager and OnlineManager to trigger refetch on focus/visibility and when coming back online. - Rewrote session-refresh to use and initialize these managers, replacing direct event listeners. - Centralized BroadcastChannel with a global instance and setup; session-refresh now subscribes to it. - Simplified session-atom mount logic; managers handle no-op in non-browser contexts. - Exported FocusManager and OnlineManager types and symbols from the client entry. - Added Expo implementations; expo client auto-sets them up on native, uses expo-network when available, and re-exports. <sup>Written for commit ed6dde1dc70b8d485e866b7fb4ce0d3d8bc4f1be. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:49:42 -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#6162