Skip to content

createBrowserClient should not require getAll/setAll cookies when using 'tokens-only' flow #170

Closed

Description

@wong2

Description

When using createBrowserClient with the 'tokens-only' option, the getAll and setAll cookie methods are still required parameters. However, in the 'tokens-only' flow, session tokens are managed via getSession / setSession rather than cookies, so requiring cookie accessors is unnecessary and confusing.

Expected Behavior

createBrowserClient with 'tokens-only' should not require getAll and setAll cookie parameters, since the token-based flow bypasses cookie storage entirely.

// This should work without providing getAll/setAll
const supabase = createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
  cookies: {
    encode: 'tokens-only',
  }
})

Current Behavior

TypeScript requires getAll and setAll to be provided even when using 'tokens-only', which forces users to pass in no-op stubs:

const supabase = createBrowserClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
  cookies: {
    encode: 'tokens-only',
    getAll: () => [], // unnecessary
    setAll: () => {}, // unnecessary
  },
})

Activity

  1. ylemkimon commented on Apr 18, 2026

    @ylemkimon

    Actually, it still uses it for getting token and setting PKCE code verifiers. So the issue should be that getAll/setAll should be set to defaults when they are not set.

  2. mandarini commented on May 4, 2026

    @mandarini
    Contributor

    Hi @wong2, thank you for opening this issue! Quick clarification on the behavior first: tokens-only doesn't bypass cookies. It only moves the user object to userStorage (defaults to localStorage). The session tokens themselves and the PKCE code verifiers still flow through the cookie methods, so passing no-op getAll/setAll stubs would silently break auth. @ylemkimon's comment above is correct on that point.

    That said, the underlying ergonomic complaint is fair. createBrowserClient already falls back to document.cookie automatically when you omit the cookies option entirely, but because encode lives on the cookies object, opting into tokens-only forced you to redeclare getAll/setAll even though the library would happily use the same fallback.

    I have a fix on the way that makes getAll/setAll optional on the browser client. When both are omitted, the existing document.cookie fallback kicks in. So this will work as you originally wrote it.

  3. self-assigned this
    on May 4, 2026
  4. wong2 commented on May 4, 2026

    @wong2
    Author

    Thanks!

  5. added a commit that references this issue on May 7, 2026
    89f3f28
  6. added a commit that references this issue on May 7, 2026
  7. added a commit that references this issue on Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions