---
title: "Offline-first React Native Apps with Expo, WatermelonDB, and Supabase"
description: "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."
url: "https://swe.quest/articles/offline-first-react-native-apps-with-expo-watermelondb-and-supabase-1f52e6fbab692dbe"
canonical: "https://supabase.com/blog/react-native-offline-first-watermelon-db"
source: "Supabase"
published: "2023-10-08"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["local-first","mobile","postgres","react"]
---

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

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2023-10-08, 7 min read, How-to. Original: [https://supabase.com/blog/react-native-offline-first-watermelon-db](https://supabase.com/blog/react-native-offline-first-watermelon-db)

## Summary

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.

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)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [React](https://swe.quest/tags/react.md) (Web & mobile)

## Prerequisites

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

## Keywords

WatermelonDB, Supabase, Expo, React Native, PL/pgSQL, Supabase Realtime, SQLite

## Related posts

- [Local-first Realtime Apps with Expo and Legend-State](https://swe.quest/articles/local-first-realtime-apps-with-expo-and-legend-state-f16eaf0818ab58cf.md): Supabase · 2024-09-23 · Medium · 8 min read · Local-first & sync, Mobile, React, PostgreSQL, Real-time systems
  Expo and React Native apps can go local-first by pairing Legend-State's sync engine with Supabase.
- [Stripe-To-Postgres Sync Engine as standalone Library](https://swe.quest/articles/stripe-to-postgres-sync-engine-as-standalone-library-5645bb8e42bc855e.md): Supabase · 2025-07-15 · Medium · 3 min read · Payments & fintech, PostgreSQL, Serverless, JavaScript
  Supabase'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.
- [Cal.com launches Expert Marketplace built with Next.js and Supabase.](https://swe.quest/articles/cal-com-launches-expert-marketplace-built-with-next-js-and-supabase-2659e9baa272f3f6.md): Supabase · 2024-06-18 · Medium · 5 min read · PostgreSQL, Frontend, Serverless, Storage systems
  Cal.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.
- [Building offline-first mobile apps with Supabase, Flutter and Brick](https://swe.quest/articles/building-offline-first-mobile-apps-with-supabase-flutter-and-brick-2c96e1b595fc5e17.md): Supabase · 2024-10-08 · Medium · 6 min read · Local-first & sync, Mobile, Caching, SQLite
  Brick 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.
- [Supabase CLI](https://swe.quest/articles/supabase-cli-a62c53c7dbec808f.md): Supabase · 2021-03-31 · Medium · 7 min read · Schema migrations, PostgreSQL, Developer tools
  Supabase'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.

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)
