Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 8 min read How-to mediumAdept

Local-first Realtime Apps with Expo and Legend-State

Expo 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.

Related posts

  • Offline-first React Native Apps with Expo, WatermelonDB, and Supabase

    Supabase mediumAdept

    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.

  • React Native file upload with Supabase Storage

    Supabase mediumAdept

    A React Native app built with Expo SDK 49 and Expo Router v2 can sign users in with Supabase Auth and upload images to a private Supabase Storage bucket. A Postgres storage policy restricts each user to a folder named after their auth UID. The Supabase client persists sessions in AsyncStorage, and an AuthProvider context built on onAuthStateChange redirects between login and protected routes. Upload works by reading the image-picker URI as base64 with expo-file-system, decoding it to an ArrayBuffer and calling storage upload().

  • Building Local-First Apps: The Complete Guide to Offline-First Database Sync

    Turso mediumAdept

    Turso Sync brings local-first behaviour to SQLite-based apps. Local changes are captured via change data capture and pushed as logical row-level mutations, while remote changes are pulled as physical pages so replicas converge byte-for-byte. Turso's benchmarks report up to 312x faster syncs and roughly 18x less traffic than the older Embedded Replicas approach. The guide covers TypeScript setup with background push/pull loops, Last-Push-Wins conflict resolution and a transform hook for custom merges such as turning sets into increments, scoped auth tokens and JWKS, sync-aware WAL checkpointing, and experimental partial sync. It also notes that there is no CRDT or peer-to-peer support, which makes the approach a poor fit for real-time collaborative document editing.

  • Getting started with React Native authentication

    Supabase mediumAdept

    Supabase Auth can be wired into an Expo/React Native app by configuring supabase-js with AsyncStorage for session persistence and disabling URL session detection. Sessions can optionally be encrypted with an AES-256 key held in Expo SecureStore, which works around SecureStore's 2048-byte limit. The guide includes code for email/password sign-in, plus OAuth and magic-link flows that rely on a custom URL scheme, deep linking and setSession from the redirect tokens. Sign in with Apple, Google sign-in and SMS/WhatsApp OTP get only brief mentions, with pointers to the docs.

  • Supabase is now compatible with Next.js 14

    Supabase mediumAdept

    Supabase works across every Next.js 14 rendering context, including App Router Client and Server Components, Route Handlers, Server Actions and Middleware, plus the Pages Router data-fetching functions. Now that Server Actions are stable, auth and mutations can run entirely server-side next to the Server Components that fetch data. supabase-js stores sessions in localStorage by default, which doesn't exist on the server, so it has to be configured with cookie-based storage on both server and browser. The new @supabase/ssr package and a create-next-app starter template (`-e with-supabase`) wrap that boilerplate.

The quest for software engineering knowledge.

Look:
Layout: