Skip to content

powersync/dev for expo go #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 4, 2025
73 changes: 73 additions & 0 deletions client-sdk-references/react-native-and-expo/expo-go-support.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: "Expo Go Support"
description: "Support for Expo Go using @powersync/adapter-sql-js"
---

Expo Go is a sandbox environment that allows you to quickly test your application without building a development build. Our native SQLite database adapters for React Native apps (OP-SQLite and React Native Quick SQLite) cannot run in Expo Go because they require native code compilation. Specifically, PowerSync needs a SQLite implementation that can load our [Rust core extension](https://github.com/powersync-ja/powersync-sqlite-core), which isn't possible in Expo Go's prebuilt app container. To enable PowerSync in Expo Go, we provide a JavaScript-based database adapter: [`@powersync/adapter-sql-js`](https://www.npmjs.com/package/@powersync/adapter-sql-js).

# @powersync/adapter-sql-js

A development package for PowerSync which uses SQL.js to provide a pure JavaScript SQLite implementation. This eliminates the need for native dependencies and enables development with Expo Go and other JavaScript-only environments. Under the hood, it uses our custom fork [powersync-sql-js](https://github.com/powersync-ja/powersync-sql-js) - a fork of SQL.js (SQLite compiled to JavaScript via Emscripten) that loads the PowerSync's Rust core extension.

Check warning on line 10 in client-sdk-references/react-native-and-expo/expo-go-support.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

client-sdk-references/react-native-and-expo/expo-go-support.mdx#L10

Did you really mean 'Emscripten'?

<Warning>

This package is in an **alpha** release.

**Expo Go Sandbox Environment Only** This adapter is specifically designed for Expo Go and similar JavaScript-only environments. It will be much slower than native database adapters and has limitations. Every write operation triggers a complete rewrite of the entire database file to persistent storage, not just the changed data. In addition to the performance overheads, this adapter doesn't provide any of the SQLite consistency guarantees - you may end up with missing data or a corrupted database file if the app is killed while writing to the database file.

</Warning>

## Usage

```bash
npm install @powersync/adapter-sql-js
```

```js SystemProvider.tsx
import { SQLJSOpenFactory } from "@powersync/adapter-sql-js";
import { PowerSyncDatabase } from "@powersync/react-native";

export const powerSync = new PowerSyncDatabase({
schema: AppSchema,
database: new SQLJSOpenFactory({
dbFilename: "example.db",
}),
});
```

### Data Persistence

The default version of this adapter uses in-memory persistence, but you can specify your own `persister` option to the open factory.
See an example in the package [README](https://www.npmjs.com/package/@powersync/adapter-sql-js).

## Moving Beyond Expo Go

When you're ready to move beyond the Expo Go sandbox environment - whether for native development builds or production deployment - we recommend switching to our native database adapters:

- [OP-SQLite](https://www.npmjs.com/package/@powersync/op-sqlite) (Recommended) - Offers built-in encryption support and better React Native New Architecture compatibility
- [React Native Quick SQLite](https://www.npmjs.com/package/@journeyapps/react-native-quick-sqlite) - Our original native adapter

These adapters provide better performance, full SQLite consistency guarantees, and are suitable for both development builds and production deployment. See the SDKs [Installation](/client-sdk-references/react-native-and-expo#install-peer-dependencies) details for setup instructions.

### Switching Between Adapters - Example

If you want to keep using Expo Go alongside development and production builds, you can switch between different adapters based on the Expo `executionEnvironment`:

```js SystemProvider.tsx
import { SQLJSOpenFactory } from "@powersync/adapter-sql-js";
import { PowerSyncDatabase } from "@powersync/react-native";
import Constants from "expo-constants";

const isExpoGo = Constants.executionEnvironment === "storeClient";

export const powerSync = new PowerSyncDatabase({
schema: AppSchema,
database: isExpoGo
? new SQLJSOpenFactory({
dbFilename: "app.db",
})
: {
dbFilename: "sqlite.db",
},
});
```
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
"icon": "react",
"pages": [
"client-sdk-references/react-native-and-expo",
"client-sdk-references/react-native-and-expo/expo-go-support",
"client-sdk-references/react-native-and-expo/react-native-web-support",
"client-sdk-references/react-native-and-expo/javascript-orm-support",
"client-sdk-references/react-native-and-expo/usage-examples",
Expand Down
49 changes: 39 additions & 10 deletions snippets/react-native/installation.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<Warning>
**PowerSync is not compatible with Expo Go.**
PowerSync uses a native plugin and is therefore only compatible with Expo Dev Builds.
</Warning>

Add the [PowerSync React Native NPM package](https://www.npmjs.com/package/@powersync/react-native) to your project:

<Tabs>
Expand All @@ -25,9 +20,45 @@ Add the [PowerSync React Native NPM package](https://www.npmjs.com/package/@powe
</Tab>
</Tabs>

**Required peer dependencies**

This SDK requires [@journeyapps/react-native-quick-sqlite](https://www.npmjs.com/package/@journeyapps/react-native-quick-sqlite) as a peer dependency. Install it as follows:
### Install peer dependencies

PowerSync requires a SQLite database adapter.

<Tip>
**Using Expo Go?** Our native database adapters listed below (OP-SQLite and React Native Quick SQLite) are not compatible with Expo Go's sandbox environment. To run PowerSync with Expo Go install our JavaScript-based adapter `@powersync/adapter-sql-js` instead. See details [here](/client-sdk-references/react-native-and-expo/expo-go-support).
</Tip>

Choose between:

**OP-SQLite (Recommended)**

[PowerSync OP-SQLite](https://www.npmjs.com/package/@powersync/op-sqlite) offers:
- Built-in encryption support via SQLCipher
- Smoother transition to React Native's New Architecture

<Tabs>
<Tab title="npm">
```bash
npx expo install @powersync/op-sqlite @op-engineering/op-sqlite
```
</Tab>

<Tab title="yarn">
```bash
yarn expo add @powersync/op-sqlite @op-engineering/op-sqlite
```
</Tab>

<Tab title="pnpm">
```
pnpm expo install @powersync/op-sqlite @op-engineering/op-sqlite
```
</Tab>
</Tabs>

**React Native Quick SQLite**

The [@journeyapps/react-native-quick-sqlite](https://www.npmjs.com/package/@journeyapps/react-native-quick-sqlite) package is the original database adapter for React Native and therefore more battle-tested in production environments.

<Tabs>
<Tab title="npm">
Expand All @@ -49,8 +80,6 @@ This SDK requires [@journeyapps/react-native-quick-sqlite](https://www.npmjs.com
</Tab>
</Tabs>

Alternatively, you can install OP-SQLite with the [PowerSync OP-SQLite package](https://github.com/powersync-ja/powersync-js/tree/main/packages/powersync-op-sqlite) which offers [built-in encryption support via SQLCipher](/usage/use-case-examples/data-encryption) and a smoother transition to React Native's New Architecture.

<Info>
**Polyfills and additional notes:**

Expand Down