[PR #7625] [MERGED] feat: add setShouldSkipSessionRefresh #7449

Closed
opened 2026-03-13 13:36:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7625
Author: @himself65
Created: 1/26/2026
Status: Merged
Merged: 1/27/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/26/state


📝 Commits (3)

📊 Changes

8 files changed (+54 additions, -7 deletions)

View changed files

📝 packages/better-auth/src/api/index.ts (+6 -1)
📝 packages/better-auth/src/api/middlewares/index.ts (+5 -2)
📝 packages/better-auth/src/api/routes/session.ts (+10 -2)
📝 packages/better-auth/src/api/state/oauth.ts (+0 -0)
packages/better-auth/src/api/state/should-session-refresh.ts (+14 -0)
📝 packages/better-auth/src/integrations/next-js.ts (+16 -0)
📝 packages/better-auth/src/oauth2/state.ts (+1 -1)
📝 packages/better-auth/src/social.test.ts (+2 -1)

📄 Description

Fixes: https://github.com/better-auth/better-auth/pull/7619
Closes: https://github.com/better-auth/better-auth/issues/2115


Summary by cubic

Add a request-scoped flag to skip session refresh and integrate it with Next.js RSC requests to prevent cookie/DB mismatches. Also consolidates OAuth state utilities and updates related exports and imports.

  • New Features

    • Added getShouldSkipSessionRefresh/setShouldSkipSessionRefresh request state.
    • Session route respects the flag to skip refresh when set.
    • Next.js integration auto-sets the flag for RSC reads (RSC=1 without Next-Action).
  • Refactors

    • Moved OAuth state helpers to api/state/oauth and updated imports/exports.
    • Simplified middleware exports to originCheck, originCheckMiddleware, and formCsrfMiddleware.
    • Updated type imports to ../types and fixed test imports.

Written for commit 29f279e23e. Summary will update 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/7625 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/26/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/26/state` --- ### 📝 Commits (3) - [`f4aa70f`](https://github.com/better-auth/better-auth/commit/f4aa70f0e6bf355c0862453c3d9a06c8ce307152) feat: add `setShouldSkipSessionRefresh` - [`fa1ffbb`](https://github.com/better-auth/better-auth/commit/fa1ffbb2e24ef95daf4fa10541d2b978be65143b) fix: export - [`29f279e`](https://github.com/better-auth/better-auth/commit/29f279e23e8f11dca7914fba4007a5889dc5a9b6) chore: lint fix ### 📊 Changes **8 files changed** (+54 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/index.ts` (+6 -1) 📝 `packages/better-auth/src/api/middlewares/index.ts` (+5 -2) 📝 `packages/better-auth/src/api/routes/session.ts` (+10 -2) 📝 `packages/better-auth/src/api/state/oauth.ts` (+0 -0) ➕ `packages/better-auth/src/api/state/should-session-refresh.ts` (+14 -0) 📝 `packages/better-auth/src/integrations/next-js.ts` (+16 -0) 📝 `packages/better-auth/src/oauth2/state.ts` (+1 -1) 📝 `packages/better-auth/src/social.test.ts` (+2 -1) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/pull/7619 Closes: https://github.com/better-auth/better-auth/issues/2115 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add a request-scoped flag to skip session refresh and integrate it with Next.js RSC requests to prevent cookie/DB mismatches. Also consolidates OAuth state utilities and updates related exports and imports. - **New Features** - Added getShouldSkipSessionRefresh/setShouldSkipSessionRefresh request state. - Session route respects the flag to skip refresh when set. - Next.js integration auto-sets the flag for RSC reads (RSC=1 without Next-Action). - **Refactors** - Moved OAuth state helpers to api/state/oauth and updated imports/exports. - Simplified middleware exports to originCheck, originCheckMiddleware, and formCsrfMiddleware. - Updated type imports to ../types and fixed test imports. <sup>Written for commit 29f279e23e8f11dca7914fba4007a5889dc5a9b6. Summary will update 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 13:36:51 -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#7449