AgentSkillsCN

powersync

使用 PowerSync 构建本地优先、离线可用的 TypeScript 应用。适用于在 SQLite 与后端数据库(Postgres、MongoDB、MySQL、SQL Server)之间实现实时同步。涵盖模式定义、数据库设置、CRUD 操作、React/Vue 钩子、watch 查询以及 Kysely/Drizzle ORM 集成。

SKILL.md
--- frontmatter
name: powersync
version: 1.0.0
description: Build local-first, offline-capable TypeScript apps with PowerSync. Use when implementing real-time sync between SQLite and backend databases (Postgres, MongoDB, MySQL, SQL Server). Covers schema definition, database setup, CRUD operations, React/Vue hooks, watch queries, and Kysely/Drizzle ORM integration.
license: Apache-2.0
metadata:
  author: ai-standards
  language: typescript
  frameworks: react, react-native, vue, node
compatibility: Node.js 18+, TypeScript 4.7+
allowed-tools: Read Write Edit Bash Grep Glob

PowerSync 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

PlatformPackage
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

  1. Schemadocs · example
  2. Databasedocs · example
  3. Connectordocs · example

API Quick Reference

OperationMethod
Get onedb.get(sql, params) / db.getOptional(sql, params)
Get alldb.getAll(sql, params)
Executedb.execute(sql, params)
Transactiondb.writeTransaction(async (tx) => { ... })
Watchdb.query({sql, parameters}).watch()
Diff watchdb.query({sql, parameters}).differentialWatch()

Full CRUD: docs

React Hooks

HookPurpose
useQueryQuery with loading/error states
useSuspenseQueryQuery with Suspense
useStatusConnection status
usePowerSyncDatabase instance

Docs: React · Vue

ORM Integration

ORMDocsExample
Kyselydocssource
Drizzledocssource
TanStack DBdocsdemo

Documentation

Local References

  • references/sync-rules.md - Sync Rules configuration
  • references/examples.md - All official example projects

GitHub Source

powersync-ja/powersync-js

PackageDescription
commonShared core (schema, sync, types)
webWeb SDK
react-nativeReact Native SDK
nodeNode.js SDK
capacitorCapacitor SDK
reactReact hooks
vueVue composables
tanstack-react-queryTanStack Query integration
kysely-driverKysely ORM driver
drizzle-driverDrizzle ORM driver
attachmentsFile attachments helper
powersync-op-sqliteOP-SQLite adapter
adapter-sql-jsSQL.js adapter (Expo Go)