> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powersync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Expo Go Support

> Run PowerSync in Expo Go without native modules using @powersync/adapter-sql-js.

Expo Go is a sandbox environment that allows you to quickly test your application without building a development build. 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

`@powersync/adapter-sql-js` is 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 SQLite core extension](https://github.com/powersync-ja/powersync-sqlite-core).

<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

<Tabs>
  <Tab title="New App">
    ### Quickstart

    1. Create a new Expo app:

    ```bash theme={null}
    npx create-expo-app@latest my-app
    ```

    2. Navigate to your app directory and start the development server:

    ```bash theme={null}
    cd my-app && npm run ios
    ```

    3. In a new terminal tab, install PowerSync dependencies:

    ```bash theme={null}
    npm install @powersync/react-native @powersync/adapter-sql-js
    ```

    4. Replace the code in `app/(tabs)/index.tsx` with:

    ```tsx app/(tabs)/index.tsx theme={null}
    import { SQLJSOpenFactory } from "@powersync/adapter-sql-js";
    import { PowerSyncDatabase, Schema } from "@powersync/react-native";
    import { useEffect, useState } from "react";
    import { Text } from "react-native";

    export const powerSync = new PowerSyncDatabase({
      schema: new Schema({}), // todo: define the schema - see Next Steps below
      database: new SQLJSOpenFactory({
        dbFilename: "example.db",
      }),
    });

    export default function HomeScreen() {
      const [version, setVersion] = useState<string | null>(null);

      useEffect(() => {
        powerSync.get("select powersync_rs_version();").then((r) => {setVersion(JSON.stringify(r))});
      }, []);

      return (
          <>{version && <Text style={{fontSize: 24, fontWeight: 'bold'}}>PowerSync Initialized - {version}</Text>}</>
      );
    }
    ```
  </Tab>

  <Tab title="Existing App">
    1. Install the SQL.js adapter:

    ```bash theme={null}
    npm install @powersync/adapter-sql-js
    ```

    2. Set up PowerSync by using the Sql.js factory:

    ```tsx SystemProvider.tsx theme={null}
    import { SQLJSOpenFactory } from "@powersync/adapter-sql-js";
    import { PowerSyncDatabase, Schema } from "@powersync/react-native";
    import { useEffect, useState } from "react";
    import { Text } from "react-native";

    export const powerSync = new PowerSyncDatabase({
      schema: new Schema({}), // todo: define the schema - see Next Steps below
      database: new SQLJSOpenFactory({
        dbFilename: "example.db",
      }),
    });

    export default function HomeScreen() {
      const [version, setVersion] = useState<string | null>(null);

      useEffect(() => {
        powerSync.get("select powersync_rs_version();").then((r) => {setVersion(JSON.stringify(r))});
      }, []);

      return (
          <>{version && <Text style={{fontSize: 24, fontWeight: 'bold'}}>PowerSync Initialized - {version}</Text>}</>
      );
    }
    ```
  </Tab>
</Tabs>

## Next Steps

After adding PowerSync to your app:

1. [**Define what data to sync by setting up Sync Rules**](/sync/rules/overview)
2. [**Implement your SQLite client schema**](/client-sdks/reference/react-native-and-expo#1-define-the-client-side-schema)
3. [**Connect to PowerSync and your backend**](/client-sdks/reference/react-native-and-expo#3-integrate-with-your-backend)

## 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

<Note>
  These database adapters cannot run in Expo Go because they require native code compilation. Specifically, PowerSync needs a SQLite implementation that can load the PowerSync SQLite core extension, which isn't possible in Expo Go's prebuilt app container.
</Note>

These adapters provide better performance, full SQLite consistency guarantees, and are suitable for both development builds and production deployment. See the SDKs [Installation](/client-sdks/reference/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 theme={null}
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",
      },
});
```
