Skip to content

fix: apply non-browser defaults when cookies only sets encode - #294

Merged
mandarini merged 1 commit into
supabase:mainfrom
PhuocOng:fix-encode-only-non-browser
Sep 8, 2026
Merged

mandarini merged 1 commit into
supabase:mainfrom
PhuocOng:fix-encode-only-non-browser

Conversation

@PhuocOng

@PhuocOng PhuocOng commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #293.

createBrowserClient with cookies: { encode: "tokens-only" } and no accessors throws outside a browser runtime (for example Next.js pre-rendering), while omitting cookies entirely works there. #213 added the encode-only fallback but only mirrored the document.cookie branch, so the non-browser branch was skipped:

  • cookies: { encode: "tokens-only" } -> createBrowserClient requires configuring getAll and setAll cookie methods
  • the same plus getAll/setAll -> ReferenceError: window is not defined (from userStorage: window.localStorage)

A cookies object without get/getAll is now treated the same as omitting cookies, so every runtime goes through the existing defaults (document.cookie in browsers, the empty getAll plus lazy-throwing setAll elsewhere), and the encode-only branch from #213 is no longer needed. userStorage falls back to memoryLocalStorageAdapter() outside a browser, matching createServerClient.

Tests: two cases in createBrowserClient.spec.ts run without a window stub; both fail on main and pass here. Full suite 120/120, prettier --check, eslint and both tsc builds clean.

@PhuocOng
PhuocOng requested review from a team as code owners September 5, 2026 17:16

@mandarini mandarini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a nice clean fix.

@mandarini
mandarini merged commit 9d6e2a5 into supabase:main Sep 8, 2026
4 checks passed
mandarini pushed a commit that referenced this pull request Sep 8, 2026
🤖 I have created a release *beep* *boop*
---


## [0.12.7](v0.12.6...v0.12.7)
(2026-09-08)


### Bug Fixes

* apply non-browser defaults when cookies only sets encode
([#294](#294))
([9d6e2a5](9d6e2a5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createBrowserClient with cookies: { encode: "tokens-only" } throws outside a browser runtime (Next.js pre-rendering)

2 participants