[PR #4378] [MERGED] fix(expo): fix signout clobbering store session properties #30946

Closed
opened 2026-04-17 21:55:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4378
Author: @aarync
Created: 9/3/2025
Status: Merged
Merged: 9/3/2025
Merged by: @himself65

Base: canaryHead: fix/expo-signout-session-clobber


📝 Commits (1)

  • 8791b08 fix(expo): fix signout clobbering store session properties

📊 Changes

2 files changed (+15 additions, -1 deletions)

View changed files

📝 packages/expo/src/client.ts (+1 -0)
📝 packages/expo/src/expo.test.ts (+14 -1)

📄 Description

Clearly describe what changes you made and why:
Keep previous store session properties when signing out, both refetch and isRefetching are no longer present in authClient.useSession() after calling authClient.signout().

Include any relevant context or background
Hit this trying to implement a signout flow for an expo app.

After calling auth.signout() the following code no longer works

function Confirmation() {
  const { data: session, refetch } = auth.useSession()

  async function handleContinue(body) {
    const { data } = await auth.emailOtp.verifyEmail(...)

    if (data) {
      // refetch is undefined after calling signout preventing the useSession
      // hook triggering updates when needed.
      refetch()
    }
  })
 ...
}

Note also updated the expo client tests to use the react client from better-auth/react

List any breaking changes or deprecations

Add screenshots for UI changes

Reference related issues or discussions


Summary by cubic

Prevented sign out from clobbering the client session store in the Expo auth client so useSession keeps its fields (e.g., refetch, isRefetching) intact. This fixes broken post-signout flows that rely on refetch.

  • Bug Fixes
    • Preserve existing session store fields on sign out by spreading prior state; only set data, error, and isPending.
    • Added a regression test for state preservation and updated tests to use better-auth/react.

🔄 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/4378 **Author:** [@aarync](https://github.com/aarync) **Created:** 9/3/2025 **Status:** ✅ Merged **Merged:** 9/3/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/expo-signout-session-clobber` --- ### 📝 Commits (1) - [`8791b08`](https://github.com/better-auth/better-auth/commit/8791b08ecb3da705413a3327c312241cc0f1d027) fix(expo): fix signout clobbering store session properties ### 📊 Changes **2 files changed** (+15 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/expo/src/client.ts` (+1 -0) 📝 `packages/expo/src/expo.test.ts` (+14 -1) </details> ### 📄 Description **Clearly describe what changes you made and why:** Keep previous store session properties when signing out, both `refetch` and `isRefetching` are no longer present in `authClient.useSession()` after calling `authClient.signout()`. **Include any relevant context or background** Hit this trying to implement a signout flow for an expo app. After calling `auth.signout()` the following code no longer works ```typescript function Confirmation() { const { data: session, refetch } = auth.useSession() async function handleContinue(body) { const { data } = await auth.emailOtp.verifyEmail(...) if (data) { // refetch is undefined after calling signout preventing the useSession // hook triggering updates when needed. refetch() } }) ... } ``` *Note* also updated the expo client tests to use the react client from `better-auth/react` ~~**List any breaking changes or deprecations**~~ ~~**Add screenshots for UI changes**~~ ~~**Reference related issues or discussions**~~ <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevented sign out from clobbering the client session store in the Expo auth client so useSession keeps its fields (e.g., refetch, isRefetching) intact. This fixes broken post-signout flows that rely on refetch. - **Bug Fixes** - Preserve existing session store fields on sign out by spreading prior state; only set data, error, and isPending. - Added a regression test for state preservation and updated tests to use better-auth/react. <!-- 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-04-17 21:55:35 -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#30946