[PR #3890] [MERGED] feat: add query parameter to useSession().refetch() for cache control consistency #5064

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3890
Author: @adriandlam
Created: 8/8/2025
Status: Merged
Merged: 8/29/2025
Merged by: @himself65

Base: canaryHead: feat/use-session-refetch-query-params


📝 Commits (9)

  • 4c5a419 feat: add query parameter support to useSession().refetch() for cache control consistency
  • 78287d3 fix: use stronger typing for refetch query parameters
  • 8377f34 fix(test): use proper type instead of any in type test
  • 2293a56 style: format tests
  • f2db36b Merge branch 'canary' into feat/use-session-refetch-query-params
  • b7ef91b Merge branch 'canary' into feat/use-session-refetch-query-params
  • 0d1da51 Merge branch 'canary' into feat/use-session-refetch-query-params
  • ddfbfb3 Merge branch 'canary' into feat/use-session-refetch-query-params
  • 2fb889a fix: lint

📊 Changes

4 files changed (+51 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/client/client.test.ts (+35 -1)
📝 packages/better-auth/src/client/query.ts (+9 -4)
📝 packages/better-auth/src/client/react/index.ts (+2 -1)
📝 packages/better-auth/src/client/types.ts (+5 -0)

📄 Description

Closes #3889

This PR adds query parameter (disableCookieCache and disableRefresh) to useSession().refetch() for consistency with getSession().

Currently, getSession() supports query parameters like { disableCookieCache: true }, but useSession().refetch() doesn't, creating an inconsistent API where developers need to import both methods.

Now you can use:

const { refetch } = useSession();
await refetch({ query: { disableCookieCache: true }});

Summary by cubic

Added support for query parameters to useSession().refetch(), making its API consistent with getSession() and allowing cache control options.

  • New Features
  • You can now pass query options like disableCookieCache and disableRefresh to refetch.

🔄 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/3890 **Author:** [@adriandlam](https://github.com/adriandlam) **Created:** 8/8/2025 **Status:** ✅ Merged **Merged:** 8/29/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `feat/use-session-refetch-query-params` --- ### 📝 Commits (9) - [`4c5a419`](https://github.com/better-auth/better-auth/commit/4c5a41910b254889bd3b5d67c74ff2082751c5fb) feat: add query parameter support to useSession().refetch() for cache control consistency - [`78287d3`](https://github.com/better-auth/better-auth/commit/78287d344adb185c8fbd763d566b31ae75b83f97) fix: use stronger typing for refetch query parameters - [`8377f34`](https://github.com/better-auth/better-auth/commit/8377f346d38a4240276980dca9debc8db7277812) fix(test): use proper type instead of any in type test - [`2293a56`](https://github.com/better-auth/better-auth/commit/2293a5671055069bd3852f649538d64f2508d778) style: format tests - [`f2db36b`](https://github.com/better-auth/better-auth/commit/f2db36bdd545e418b505c859f798f9d5459ba72c) Merge branch 'canary' into feat/use-session-refetch-query-params - [`b7ef91b`](https://github.com/better-auth/better-auth/commit/b7ef91b136ceef8e25ca0e577c896c9523ec48da) Merge branch 'canary' into feat/use-session-refetch-query-params - [`0d1da51`](https://github.com/better-auth/better-auth/commit/0d1da512627a7b76471c2286525573d4cbd026d5) Merge branch 'canary' into feat/use-session-refetch-query-params - [`ddfbfb3`](https://github.com/better-auth/better-auth/commit/ddfbfb35fd52888bb12383747de2f1caae547c55) Merge branch 'canary' into feat/use-session-refetch-query-params - [`2fb889a`](https://github.com/better-auth/better-auth/commit/2fb889a93deea1c0c5059f1b1d23f557119846c8) fix: lint ### 📊 Changes **4 files changed** (+51 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/client.test.ts` (+35 -1) 📝 `packages/better-auth/src/client/query.ts` (+9 -4) 📝 `packages/better-auth/src/client/react/index.ts` (+2 -1) 📝 `packages/better-auth/src/client/types.ts` (+5 -0) </details> ### 📄 Description Closes #3889 This PR adds query parameter (`disableCookieCache` and `disableRefresh`) to `useSession().refetch()` for consistency with `getSession()`. Currently, `getSession()` supports query parameters like `{ disableCookieCache: true }`, but `useSession().refetch()` doesn't, creating an inconsistent API where developers need to import both methods. Now you can use: ```ts const { refetch } = useSession(); await refetch({ query: { disableCookieCache: true }}); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added support for query parameters to useSession().refetch(), making its API consistent with getSession() and allowing cache control options. - **New Features** - You can now pass query options like disableCookieCache and disableRefresh to refetch. <!-- 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:09: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#5064