Offline-first React Native Apps with Expo, WatermelonDB, and Supabase
An offline-first React Native/Expo app can use WatermelonDB (SQLite-based, last-write-wins sync) as its local store and sync to Supabase Postgres through two RPC calls: a `push` function that applies client changesets and a `pull` function that returns all changes since the last sync timestamp. The walkthrough covers adding simdjson via expo-build-properties, defining WatermelonDB models, and writing the PL/pgSQL push/pull and epoch-conversion functions, with soft deletes tracked via deleted_at/last_modified_at. The main tradeoff is friction when changing the data model, since the Postgres schema, the local WatermelonDB schema and the sync functions must all be kept in step. That makes the approach best suited to apps with a stable schema where snappy interactions matter.
Related posts
- Local-first Realtime Apps with Expo and Legend-State
Supabase mediumAdeptExpo and React Native apps can go local-first by pairing Legend-State's sync engine with Supabase. Changes are written to Async Storage and retried with exponential backoff until Supabase confirms them, then server fields like updated_at are merged back into local state. The walkthrough configures syncedSupabase with incremental 'last-sync' diffs, soft deletes and realtime, and uses a Postgres trigger to maintain created_at/updated_at. It also covers generated TypeScript types, observer components for fine-grained re-renders, and client-side UUID generation for offline inserts.
- Stripe-To-Postgres Sync Engine as standalone Library
Supabase mediumAdeptSupabase's stripe-sync-engine, a webhook listener that normalizes Stripe events into relational Postgres tables, is now published as the npm package @supabase/stripe-sync-engine instead of only a Docker image. It can run in Node.js, Express or Supabase Edge Functions via a StripeSync class whose processWebhook method takes the raw body and signature. Schema migrations should be run separately with runMigrations or folded into the regular migration workflow, after which incoming webhooks populate a stripe schema. Keeping Stripe data local avoids API round-trips and enables joins for billing dashboards, fraud checks and dunning workflows.
- Cal.com launches Expert Marketplace built with Next.js and Supabase.
Supabase mediumAdeptCal.com's open-source Platform Starter Kit for building expert marketplaces runs on Next.js and Supabase, having switched from SQLite to Postgres via Prisma shortly before launch once file storage was needed. Prisma connects through Supavisor using a pooled transaction-mode URL plus a direct session-mode URL, and its multiSchema feature keeps app tables out of the PostgREST-exposed public schema. Profile images upload to Supabase Storage via server-generated signed upload URLs, which works alongside Auth.js rather than Supabase Auth, and a custom Next.js Image loader serves resized images. A Vercel integration syncs environment variables and can provision a project with migrations and seeds in one click.
- Building offline-first mobile apps with Supabase, Flutter and Brick
Supabase mediumAdeptBrick is a Flutter data manager that keeps Supabase data in local SQLite and optional in-memory caches so apps behave the same with or without connectivity. Requests made offline are queued and retried until the device reconnects, and caching can be skipped per request for sensitive or must-be-fresh data. Setup walks through annotated Dart models with client-generated UUID keys (never auto-increment, so distributed clients avoid collisions) and build_runner code generation that produces adapters and SQLite migrations, which should still be reviewed. A single repository handles queries and upserts, and the guide also covers local reactive streams (not yet wired to Supabase realtime), associations, and a mock Supabase server for unit tests.
- Supabase CLI
Supabase mediumAdeptSupabase's new CLI runs the full Supabase stack locally via Docker Compose, using the same tooling as production, and walks through wiring it to a React app. For migrations, Supabase prefers schema diffing over hand-written migration scripts. After evaluating migra, dbdiff, pgdiff, apgdiff, pgquarrel and pgAdmin Schema Diff, it picked pgAdmin's because it tracks VIEW owner changes, which Row Level Security on views depends on, and it also handles domains. Since pgAdmin's diff was GUI-only, Supabase built a CLI mode for it and shipped it as a Docker image. A `supabase eject` command emits docker-compose, Kong and Postgres configs for self-hosting.