powersync
Scannednpx machina-cli add skill guillempuche/ai-standards/powersync --openclawPowerSync TypeScript Skill
Sync engine for local-first apps with real-time sync between client SQLite and backend databases.
When to Use
- Offline-first/local-first applications
- Real-time sync between client and server
- Instant UI responsiveness with background sync
Installation
| Platform | Package |
|---|---|
| Web | @powersync/web + @journeyapps/wa-sqlite |
| React Native | @powersync/react-native + @powersync/op-sqlite |
| React hooks | @powersync/react |
| Vue composables | @powersync/vue |
| Node.js | @powersync/node |
| Kysely ORM | @powersync/kysely-driver |
| Drizzle ORM | @powersync/drizzle-driver |
Core Setup
API Quick Reference
| Operation | Method |
|---|---|
| Get one | db.get(sql, params) / db.getOptional(sql, params) |
| Get all | db.getAll(sql, params) |
| Execute | db.execute(sql, params) |
| Transaction | db.writeTransaction(async (tx) => { ... }) |
| Watch | db.query({sql, parameters}).watch() |
| Diff watch | db.query({sql, parameters}).differentialWatch() |
Full CRUD: docs
React Hooks
| Hook | Purpose |
|---|---|
useQuery | Query with loading/error states |
useSuspenseQuery | Query with Suspense |
useStatus | Connection status |
usePowerSync | Database instance |
ORM Integration
| ORM | Docs | Example |
|---|---|---|
| Kysely | docs | source |
| Drizzle | docs | source |
| TanStack DB | docs | demo |
Documentation
Local References
references/sync-rules.md- Sync Rules configurationreferences/examples.md- All official example projects
GitHub Source
| Package | Description |
|---|---|
| common | Shared core (schema, sync, types) |
| web | Web SDK |
| react-native | React Native SDK |
| node | Node.js SDK |
| capacitor | Capacitor SDK |
| react | React hooks |
| vue | Vue composables |
| tanstack-react-query | TanStack Query integration |
| kysely-driver | Kysely ORM driver |
| drizzle-driver | Drizzle ORM driver |
| attachments | File attachments helper |
| powersync-op-sqlite | OP-SQLite adapter |
| adapter-sql-js | SQL.js adapter (Expo Go) |
Source
git clone https://github.com/guillempuche/ai-standards/blob/main/skills/powersync/SKILL.mdView on GitHub Overview
PowerSync is a TypeScript-based sync engine for local-first apps that enables real-time synchronization between the client-side SQLite database and backend databases such as Postgres, MongoDB, MySQL, and SQL Server. It covers schema definition, database setup, CRUD operations, React/Vue hooks, and ORM integrations with Kysely and Drizzle, delivering instant UI responsiveness even when offline.
How This Skill Works
You define a schema and initialize a local PowerSync database, then use provided APIs and hooks to perform CRUD operations and observe changes. The engine connects the client-side SQLite with your backend via connectors, supporting watch queries and differentialWatch, and integrates smoothly with Kysely and Drizzle ORM drivers for seamless server sync.
When to Use It
- Offline-first/local-first applications that need offline data access and syncing when online
- Applications requiring real-time synchronization between client SQLite and backend databases (Postgres, MongoDB, MySQL, SQL Server)
- User interfaces that must stay responsive with background sync and live updates
- Mobile or React Native apps with intermittent connectivity and seamless data reconciliation
- Projects leveraging Kysely or Drizzle ORM to manage cross-database data synchronization
Quick Start
- Step 1: Define your schema using the provided schema definitions and docs
- Step 2: Instantiate the local PowerSync database and connect to your backend
- Step 3: Use React/Vue hooks and the CRUD APIs to build your UI and start syncing
Best Practices
- Define a strong, explicit schema early and align it with your backend models
- Use watch() and differentialWatch() to drive reactive UI updates and minimize polling
- Prefer transactional operations (db.writeTransaction) for atomic multi-step changes
- Test offline scenarios and conflict resolution strategies across devices
- Choose the appropriate ORM driver (Kysely/Drizzle) and follow their integration docs for best compatibility
Example Use Cases
- Offline-first to-do app with real-time sync to Postgres
- Field data collection app syncing locally to MongoDB in the backend
- Inventory management system with live stock updates across devices
- Customer support chat app with offline messaging and server sync
- Mobile note-taking app syncing to SQL Server for centralized access