---
title: "Local-first Realtime Apps with Expo and Legend-State"
description: "Expo and React Native apps can go local-first by pairing Legend-State's sync engine with Supabase."
url: "https://swe.quest/articles/local-first-realtime-apps-with-expo-and-legend-state-f16eaf0818ab58cf"
canonical: "https://supabase.com/blog/local-first-expo-legend-state"
source: "Supabase"
published: "2024-09-23"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["local-first","mobile","react","postgres","realtime"]
---

# Local-first Realtime Apps with Expo and Legend-State

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2024-09-23, 8 min read, How-to. Original: [https://supabase.com/blog/local-first-expo-legend-state](https://supabase.com/blog/local-first-expo-legend-state)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Local-first & sync](https://swe.quest/tags/local-first.md) (Architecture & design)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Real-time systems](https://swe.quest/tags/realtime.md) (Backend & APIs)

## Prerequisites

- React Native basics ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- Supabase/Postgres basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- React state management ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))

## Keywords

Legend-State, Supabase, Expo, React Native, Async Storage, supabase-js

## Related posts

- [Offline-first React Native Apps with Expo, WatermelonDB, and Supabase](https://swe.quest/articles/offline-first-react-native-apps-with-expo-watermelondb-and-supabase-1f52e6fbab692dbe.md): Supabase · 2023-10-08 · Medium · 7 min read · Local-first & sync, Mobile, PostgreSQL, React
  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.
- [React Native file upload with Supabase Storage](https://swe.quest/articles/react-native-file-upload-with-supabase-storage-8dde735f893aa350.md): Supabase · 2023-08-01 · Medium · 14 min read · React, Mobile, Identity & auth, Storage systems
  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.
- [Building Local-First Apps: The Complete Guide to Offline-First Database Sync](https://swe.quest/articles/building-local-first-apps-the-complete-guide-to-offline-first-database-sync-047687e423c4421f.md): Turso · 2026-07-27 · Medium · 9 min read · Local-first & sync, SQLite, Replication, Consistency models, TypeScript
  Turso Sync brings local-first behaviour to SQLite-based apps.
- [Getting started with React Native authentication](https://swe.quest/articles/getting-started-with-react-native-authentication-41c0c8f4add48c30.md): Supabase · 2023-11-16 · Medium · 9 min read · Identity & auth, Mobile, React, TypeScript
  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.
- [Supabase is now compatible with Next.js 14](https://swe.quest/articles/supabase-is-now-compatible-with-next-js-14-76a3d4ceac89740e.md): Supabase · 2023-11-01 · Medium · 4 min read · React, Frontend, Identity & auth, JavaScript
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
