npx create-expo-app@latest my-app
cd my-app && npm run ios
- Open a new terminal tab:
npm install @powersync/react-native @powersync/adapter-sql-js
- Replace code in
app/(tabs)/index.tsx
:
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({}),
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>}</>
);
}
At this point everything should work 😃
- Implement your SQLite client schema
- Connect to PowerSync and your backend - instructions