Supabase
Point Flux at an existing Supabase client and it takes care of turning Postgres change events into live store updates — reconnect handling, single-socket coordination across tabs, and catch-up after time offline all come for free once the adapter is wired in.
- An existing Supabase project with a table you want to sync
- The Supabase JS client already installed (@supabase/supabase-js)
- @tsworldtech/flux and @tsworldtech/flux-supabase installed
Create the adapter
createSupabaseAdapter(), then hand that to createFlux(). There's no separate connect step and nothing to await — the adapter opens a connection lazily, only once a store actually registers a channel.Register a store against a table
table is the actual Postgres table name; channel is just the name your app uses internally and can be anything you like. event controls which row operations you care about — use '*' for all of them, or scope down to just INSERT, UPDATE, or DELETE if that's all a given store needs.Turn on replication for the table
Realtime replication is off by default per table in Supabase. In the Supabase dashboard, go to Database → Replication, and toggle on the tables you want Flux to receive live updates for. A table that isn't toggled on will still work for your initial data load — it just won't push live updates until replication is enabled for it.
Delta Catch-up & Database Setup
flux_changelog SQL script in your Supabase SQL Editor.While live push updates work out-of-the-box once table Replication is enabled, catch-up delta backfill (receiving what changed while offline) requires running the single-state flux_changelog SQL script in your Supabase SQL Editor. The adapter invokes the flux_request_delta RPC function on reconnect automatically.
Channel name vs. table name
channel never has to match table — Flux only ever uses table to decide what to subscribe to on the Postgres side.Row-level security just works
Supabase's realtime replication respects Row Level Security the same way normal reads do. If a row wouldn't be visible to a signed-in user in a regular select, they won't receive an update for it over the realtime channel either. There's nothing extra to configure on the Flux side for this — it inherits whatever policies you've already set on the table.
For what happens after a reconnect specifically, see core-concepts/sync-anchors and core-concepts/activity-bus. For tables with a lot of rows where you only want detail pages cached on demand rather than all at once, see ingestion/lru.