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
createSupabaseAdapter() only handles the realtime/delta layer — Flux doesn't authenticate anyone. @tsworldtech/flux_supabase also ships isReallyOnline(), createConnectivityAwareFetch(), and resolveAuthIntent(), which cover the separate (and easy to get wrong) problem of telling a real logout apart from a session check that just failed because the device is offline. See core_concepts/offline_auth_intent.
Create the adapter
createSupabaseAdapter(), then hand that to createFlux(). There is 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 is all a given store needs.Flux identifies each row by its id column. A table whose primary key is not named id produces events with no resolvable id, and those events are dropped rather than applied under a made-up id. Catch-up rows are identified by the row_id the changelog stores.
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 is not toggled on will still work for your initial data load — it just will not push live updates until replication is enabled for it.
Delta Catch-up & Database Setup
flux_changelog SQL script in your Supabase SQL Editor, then tell the adapter how long the changelog is kept.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. If you also install flux_request_delta_batch, the adapter catches up every table in a single request; without it, the adapter falls back to one flux_request_delta call per table. Deletion reconciliation uses the flux_reconcile function from the same script.
What catch-up proves
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 would not be visible to a signed-in user in a regular select, they will not receive an update for it over the realtime channel either. There is nothing extra to configure on the Flux side for this — it inherits whatever policies you have 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. For telling a real logout apart from an offline session check, see core_concepts/offline_auth_intent.