← 返回 Skill 列表
extension
分类: 开发与工程API Key 暂未确认

powersync

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

person作者: jakexiaohubgithub

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

| 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

  1. Schema → docs · example
  2. Database → docs · example
  3. Connector → docs · example

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 |

Docs: React · Vue

ORM Integration

| ORM | Docs | Example | | ----------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | Kysely | docs | source | | Drizzle | docs | source | | TanStack DB | docs | demo |

Documentation

| Topic | URL | | ---------------- | --------------------------------------------------------------------------- | | Overview | https://docs.powersync.com/intro/powersync-overview.md | | Web SDK | https://docs.powersync.com/client-sdk-references/javascript-web.md | | React Native SDK | https://docs.powersync.com/client-sdk-references/react-native-and-expo.md | | Sync Rules | https://docs.powersync.com/usage/sync-rules.md | | Watch Queries | https://docs.powersync.com/usage/use-case-examples/watch-queries.md | | API Reference | https://powersync-ja.github.io/powersync-js/web-sdk |

Local References

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

GitHub Source

powersync-ja/powersync-js

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