[PR #6013] [MERGED] feat: support storing account data in a cookie #31984

Closed
opened 2026-04-17 22:51:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6013
Author: @Bekacru
Created: 11/16/2025
Status: Merged
Merged: 11/21/2025
Merged by: @Bekacru

Base: canaryHead: feat/account-data-cookie


📝 Commits (10+)

📊 Changes

18 files changed (+427 additions, -494 deletions)

View changed files

📝 demo/stateless/src/app/dashboard/page.tsx (+42 -1)
📝 demo/stateless/src/lib/auth.ts (+3 -0)
📝 docs/content/docs/concepts/session-management.mdx (+5 -6)
📝 docs/content/docs/errors/state_mismatch.mdx (+1 -1)
📝 docs/content/docs/reference/options.mdx (+11 -5)
📝 packages/better-auth/src/adapters/kysely-adapter/dialect.ts (+1 -1)
📝 packages/better-auth/src/api/routes/account.test.ts (+78 -0)
📝 packages/better-auth/src/api/routes/account.ts (+183 -45)
📝 packages/better-auth/src/api/routes/callback.ts (+8 -7)
packages/better-auth/src/context/__snapshots__/base.test.ts.snap (+0 -363)
📝 packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap (+13 -4)
📝 packages/better-auth/src/context/create-context.test.ts (+6 -12)
📝 packages/better-auth/src/context/create-context.ts (+5 -8)
📝 packages/better-auth/src/cookies/index.ts (+7 -0)
📝 packages/better-auth/src/oauth2/link-account.ts (+34 -14)
📝 packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts (+2 -4)
📝 packages/core/src/types/cookie.ts (+1 -0)
📝 packages/core/src/types/init-options.ts (+27 -23)

📄 Description

  • Support storing OAuth access and refresh tokens directly in a cookie so that getAccessToken and other IDP-token methods work without requiring a database

  • move oauthConfig to accounts options instead

  • intorduce new option storeAccountCookie for enabling account cookie data

  • Implementation

  • Test

  • Docs


🔄 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/6013 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 11/16/2025 **Status:** ✅ Merged **Merged:** 11/21/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/account-data-cookie` --- ### 📝 Commits (10+) - [`56652ff`](https://github.com/better-auth/better-auth/commit/56652ff6e8766c7b45d89f93ca121d76ba55e070) wip - [`34547cd`](https://github.com/better-auth/better-auth/commit/34547cdc47ff18b1b6bf8a653e6817a4cac59ae1) feat: support storing account data in a cookie - [`31ae38d`](https://github.com/better-auth/better-auth/commit/31ae38d5d306fc3a2ae462c33c2d4f011f232a2f) update docs - [`f10131a`](https://github.com/better-auth/better-auth/commit/f10131a7f2f5b3b53e918ddbc573ce401e55d37a) fix test - [`061d676`](https://github.com/better-auth/better-auth/commit/061d67648599c9a0b5b6cefa0a179029ee574795) chore: update snaphsot - [`55c6626`](https://github.com/better-auth/better-auth/commit/55c662664eaa8c589cc4c72edb618437de8ee52e) address comments - [`b3cdabd`](https://github.com/better-auth/better-auth/commit/b3cdabdbd15345d7165bd4d1b8db59672211d436) Merge branch 'canary' into feat/account-data-cookie - [`af46bed`](https://github.com/better-auth/better-auth/commit/af46bede34658baf5949fe5a6eca30c9c8fb9290) chore: update snapshot - [`6897554`](https://github.com/better-auth/better-auth/commit/6897554f4b82db79128e8ea6539ad655838aea99) Merge branch 'canary' into feat/account-data-cookie - [`bd740c4`](https://github.com/better-auth/better-auth/commit/bd740c472ec290d5dcb1245ee7ac9d24f3ced823) add demo ### 📊 Changes **18 files changed** (+427 additions, -494 deletions) <details> <summary>View changed files</summary> 📝 `demo/stateless/src/app/dashboard/page.tsx` (+42 -1) 📝 `demo/stateless/src/lib/auth.ts` (+3 -0) 📝 `docs/content/docs/concepts/session-management.mdx` (+5 -6) 📝 `docs/content/docs/errors/state_mismatch.mdx` (+1 -1) 📝 `docs/content/docs/reference/options.mdx` (+11 -5) 📝 `packages/better-auth/src/adapters/kysely-adapter/dialect.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/account.test.ts` (+78 -0) 📝 `packages/better-auth/src/api/routes/account.ts` (+183 -45) 📝 `packages/better-auth/src/api/routes/callback.ts` (+8 -7) ➖ `packages/better-auth/src/context/__snapshots__/base.test.ts.snap` (+0 -363) 📝 `packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap` (+13 -4) 📝 `packages/better-auth/src/context/create-context.test.ts` (+6 -12) 📝 `packages/better-auth/src/context/create-context.ts` (+5 -8) 📝 `packages/better-auth/src/cookies/index.ts` (+7 -0) 📝 `packages/better-auth/src/oauth2/link-account.ts` (+34 -14) 📝 `packages/better-auth/src/plugins/generic-oauth/generic-oauth.test.ts` (+2 -4) 📝 `packages/core/src/types/cookie.ts` (+1 -0) 📝 `packages/core/src/types/init-options.ts` (+27 -23) </details> ### 📄 Description - Support storing OAuth access and refresh tokens directly in a cookie so that `getAccessToken` and other IDP-token methods work without requiring a database - move `oauthConfig` to `accounts` options instead - intorduce new option `storeAccountCookie` for enabling account cookie data - [x] Implementation - [x] Test - [x] Docs --- <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 22:51:29 -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#31984