@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 - a fork of SQL.js (SQLite compiled to JavaScript via Emscripten) that loads the PowerSync SQLite core extension.
Usage
- New App
- Existing App
Quickstart
- Create a new Expo app:
- Navigate to your app directory and start the development server:
- In a new terminal tab, install PowerSync dependencies:
- Replace the code in
app/(tabs)/index.tsxwith:
app/(tabs)/index.tsx
Next Steps
After adding PowerSync to your app:- Define what data to sync by setting up Sync Rules
- Implement your SQLite client schema
- Connect to PowerSync and your backend
Data Persistence
The default version of this adapter uses in-memory persistence, but you can specify your ownpersister option to the open factory.
See an example in the package README.
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 recommended native database adapter, based on OP-SQLite.OP-SQLite cannot run in Expo Go because it 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.
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 ExpoexecutionEnvironment:
SystemProvider.tsx