Skip to content

Conversation

@mandarini
Copy link
Contributor

Summary

Adds opt-in support for including global.headers in Realtime WebSocket query params, enabling RLS policies that check request.headers to work with realtime subscriptions.

Usage:

  createClient(url, key, {
    global: { headers: { 'x-tenant-id': 'tenant-123' } },
    realtime: { includeHeadersInParams: ['x-tenant-id'] }
  })

Changes

  • New realtime.includeHeadersInParams option in createClient()
  • Specified headers are copied to WebSocket URL as query params
  • Fully backward compatible (opt-in only)

Use Case

Enables multi-tenant patterns where tenant context is passed via headers (e.g., x-tenant-id) to work with realtime subscriptions, addressing issue #1797.

@github-actions github-actions bot added the supabase-js Related to the supabase-js library. label Oct 29, 2025
@mandarini mandarini self-assigned this Oct 29, 2025
@mandarini mandarini marked this pull request as ready for review October 29, 2025 16:29
@mandarini mandarini requested a review from a team as a code owner October 29, 2025 16:29
@coveralls
Copy link

Coverage Status

coverage: 95.636% (-0.2%) from 95.853%
when pulling 19bd833 on fix/realtime-headers-ws
into e8a644e on master.

@mandarini
Copy link
Contributor Author

Closing after discussing internally with the team. Tagging @filipecabaco

@mandarini mandarini closed this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

supabase-js Related to the supabase-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants