Skip to main content
This feature requires Despia V4, currently in beta. Most Despia apps are running on Despia V3. To join the V4 beta, email beta@despia.com.
PowerSync brings a native local SQLite database to your Despia app and keeps it in real-time sync with your backend. Queries hit local storage, there is no network round-trip. The app stays fully usable offline and syncs automatically when connectivity returns.
PowerSync uses native SQLite on both iOS and Android with a production-proven sync engine. Write locally, sync in the background, read instantly, even on a plane.

Installation

npm install @despia/powersync
import { db } from '@despia/powersync';

Why we built this

Despia apps run your existing web app inside a native Swift and Kotlin runtime. Most apps rely on fetching data from a remote API on every load. That works fine on a fast connection. It breaks on slow networks, fails completely offline, and adds latency to every interaction. We wanted local-first data that works the way web developers expect: query with SQL, write normally, get results instantly. No custom sync protocols. No manual conflict resolution. No arbitrary storage limits. So we integrated PowerSync, a production-proven sync engine, directly into the Despia runtime. The result: a native SQLite database on-device, a simple JavaScript API, and automatic two-way sync with your backend.

Cross-platform by design

PowerSync is built for both iOS and Android through a unified JavaScript SDK. Write your code once. It works identically on both platforms. No iOS-specific workarounds. No Android edge cases. The API is fully standardised so you can focus on building your app instead of handling platform differences.
import { db } from '@despia/powersync'

// Same code. Both platforms.
type User = { id: number; email: string }
const users = await db.query<User>('SELECT id, email FROM users WHERE active = ?', [1])
Under the hood, Despia handles the platform-specific SQLite implementations so your JavaScript stays clean and portable.

Fully on-device. No cloud dependencies.

PowerSync runs entirely through the native runtime. Your data lives on the device. Built on native SQLite. Both iOS and Android have SQLite built into the OS. PowerSync uses these native engines directly, no third-party database, no in-memory fallback, no storage quotas. Use any backend. PowerSync syncs with your existing Postgres, MongoDB, or MySQL database through its sync rules. Despia does not sit between you and your data. No per-user fees. Unlike cloud-based solutions that charge per monthly active user, the database is on the device. Storage scales with the device, not with your user count. Works offline completely. Once data is synced, the app operates without any network connectivity. Reads and writes work locally. Pending writes are uploaded when connectivity returns.

How it works

Install the package and connect to your PowerSync instance with a JWT from your backend. After that, every query hits local SQLite.
import { db } from '@despia/powersync'

// Connect sync engine with a JWT from your backend
await db.connect({
    fetchToken: async () => {
        const res = await fetch('/api/powersync-token')
        const { token } = await res.json()
        return token
    },
    url: 'https://YOUR_POWERSYNC_INSTANCE',
})
Run migrations on startup to set up your schema:
await db.migrate(1, [
    { sql: 'CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, email TEXT)' },
    { sql: 'CREATE TABLE IF NOT EXISTS todos(id INTEGER PRIMARY KEY, title TEXT, done INTEGER DEFAULT 0)' },
])
Query and write immediately, all local, all instant:
// Query
type Todo = { id: number; title: string; done: 0 | 1 }
const todos = await db.query<Todo>('SELECT * FROM todos WHERE done = ?', [0])

// Write
await db.execute('INSERT INTO todos(title, done) VALUES(?, ?)', ['Buy milk', 0])

// Transaction
await db.transaction(async (tx) => {
    await tx.execute('UPDATE todos SET done = 1 WHERE id = ?', [todoId])
})

Live queries

Subscribe to a query and receive updates whenever the underlying data changes, including changes arriving from sync.
type Todo = { id: number; title: string; done: 0 | 1 }

const unwatch = db.watch<Todo>(
    'SELECT * FROM todos WHERE done = ?',
    [0],
    (rows) => renderTodos(rows)
)

// Stop watching when component unmounts
unwatch()
The callback fires immediately with the current result set, then again whenever a matching row changes. No polling. No manual refresh.

Sync status

Check the current sync state and subscribe to changes:
const status = await db.syncStatus()
// { connected: true, lastSynced: "2026-04-01T09:00:00Z", uploading: false, downloading: false }

const unsub = db.onSyncChange((status) => {
    updateSyncIndicator(status.connected)
})
Trigger a manual sync at any point:
await db.sync()

Use cases

Offline-first apps

Field service, logistics, and inspection apps that must work without connectivity. Data syncs when the device comes back online.

Instant UI

No loading spinners waiting for API responses. Every read hits local SQLite in milliseconds regardless of network conditions.

Real-time collaboration

Subscribe to live queries and reflect changes from other users the moment they arrive via sync.

Data-heavy apps

Store large datasets locally without hitting browser storage quotas. SQLite handles millions of rows efficiently.

Frequently asked questions

Does this work offline?

Yes. Queries and writes hit local SQLite. Once initial sync completes, the app works fully offline. Pending writes are queued and uploaded when connectivity returns.

What backends does PowerSync support?

PowerSync syncs with Postgres, MongoDB, and MySQL via sync rules you configure in the PowerSync dashboard. Despia handles the native bridge, the backend connection is between PowerSync and your database.
Yes. PowerSync is compatible with both Remote Hydration (default) and Local Server (http://localhost). The database runs in the native layer regardless of how the web app is served.
Yes. The database is compiled into the app binary. No executables are downloaded post-install. SQLite is a standard system framework on both iOS and Android.
No. PowerSync requires Despia V4. Email beta@despia.com to join the V4 beta.

Resources

NPM Package

@despia/powersync

Reference

Full API, query, execute, batch, watch, migrate, sync

PowerSync

Backend setup, schema config, and sync rules