Skip to content

fix: warn when auth.storage is ignored by createBrowserClient/createServerClient - #284

Merged
mandarini merged 2 commits into
mainfrom
fix/warn-ignored-storage-option
Aug 24, 2026
Merged

fix: warn when auth.storage is ignored by createBrowserClient/createServerClient#284
mandarini merged 2 commits into
mainfrom
fix/warn-ignored-storage-option

Conversation

@mandarini

@mandarini mandarini commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

createBrowserClient and createServerClient always store the session via cookies, so any auth.storage you pass in is silently overwritten and has no effect. This adds a one-time console warning when that option is passed, plus a short doc note (in both functions' tsdoc and the README) clarifying that auth.storage is ignored, while auth.userStorage remains respected when cookies.encode is "tokens-only".

The warning is deduped via a small warnOnce helper (kept out of the public API), so apps that create a server client per request log it once per process instead of on every request. The check also runs after the singleton short-circuit and URL/key validation, so a cached no-op createBrowserClient call or a call that's about to throw doesn't warn. Tests cover the warning firing, firing only once across multiple calls, and (behaviorally, on the server client) that the cookie-backed storage still wins over a custom auth.storage.

No behavior change: the cookie-backed storage still always wins, this only makes the existing no-op visible instead of silent.

Fixes #142

@mandarini
mandarini marked this pull request as ready for review August 14, 2026 16:52
@mandarini
mandarini requested review from a team as code owners August 14, 2026 16:52
Dedupe the auth.storage warning via a warnOnce helper so per-request
createServerClient calls don't spam logs, and move the check after the
singleton short-circuit and URL/key validation so no-op or throwing
calls don't warn. Adds warns-once tests for both clients and a
behavioral server test proving the cookie-backed storage still wins.
@mandarini
mandarini force-pushed the fix/warn-ignored-storage-option branch from 1175e70 to f923e3f Compare August 24, 2026 11:01
@mandarini mandarini self-assigned this Aug 24, 2026
@mandarini
mandarini merged commit c1700f2 into main Aug 24, 2026
5 checks passed
@mandarini
mandarini deleted the fix/warn-ignored-storage-option branch August 24, 2026 11:07
mandarini pushed a commit that referenced this pull request Aug 24, 2026
🤖 I have created a release *beep* *boop*
---


## [0.12.5](v0.12.4...v0.12.5)
(2026-08-24)


### Bug Fixes

* warn when auth.storage is ignored by
createBrowserClient/createServerClient
([#284](#284))
([c1700f2](c1700f2)),
closes [#142](#142)

---
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.

Storage: window.localstorage in createBrowserClient doesn't work

2 participants