@peers-app/peers-sdk
v0.20.6
Published
The core SDK for building [Peers](https://peers.app) packages.
Readme
@peers-app/peers-sdk
The core SDK for building Peers packages.
What is Peers?
Peers is a local-first personal computing platform. Your data lives on your devices, syncs peer-to-peer, and is end-to-end encrypted — no servers in the middle. You own your data and your identity. Build apps with the SDK or use AI coding tools to create them; either way, the platform handles sync, encryption, and persistence automatically.
What this package provides
Package System
definePackage() and the contract builder API let you declare tables, tools, assistants, screens, and navigation entries. The runtime installs, loads, and hot-reloads your package across all devices.
ORM
Table definitions with Zod schemas, data queries with a Mongo-style filter syntax, and async cursors. Tables sync across devices and encrypt automatically — you just define the schema.
Observables and Persistent Variables
Lightweight reactive primitives (observable(), computed()) with .subscribe(). Persistent variables (deviceVar, userVar, groupVar) are observables backed by the database — write once, subscribe everywhere, synced across devices.
Types and Schemas
Zod schemas and TypeScript types for the entire Peers data model: users, groups, devices, packages, tools, assistants, workflows, messages, channels, and more.
Encryption
NaCl-based key management, message signing and verification, box encryption, and deterministic hashing. Identity is a cryptographic key pair — no passwords, no email.
Tools Framework
Define AI-callable tools with ITool and IToolInstance. Tools are registered at runtime and available to built-in and user-defined AI assistants and workflows.
Identity and Groups
User, group, and permission management types. Group-scoped data contexts for multi-tenant data isolation. Invite flows and trust levels.
Quick Start
npm install @peers-app/peers-sdkThe fastest way to build a Peers package is to start from the template:
peers-package-template — scaffold, build, and install a custom package into the Peers runtime. This will be setup automatically when you create a new package in the desktop app.
Key Interfaces
| Export | Purpose |
| ------------------------------------ | ----------------------------------------------------------------------- |
| definePackage() | Entry point for declaring a package's contracts, tools, tables, and nav |
| Table | ORM table with CRUD, Zod validation, and dataChanged events |
| DataQuery / DataFilter | Mongo-style query filters translated to SQL |
| observable() / computed() | Reactive state primitives |
| deviceVar / userVar / groupVar | Persistent variables — observables backed by the database |
| ITool / IToolInstance | AI-callable tool definitions |
| IPeersUI / IPeersUIRoute | Screen and route declarations for package UIs |
| newid() | Generate 25-character time-sortable peer IDs |
| newKeys() / hydrateKeys() | Cryptographic key pair generation and hydration |
| UserContext / DataContext | Multi-group data scoping and package loading |
Links
- peers.app — try Peers in your browser or download the desktop app
- Documentation — architecture, package development, and API reference
- GitHub — source repositories and package template
License
MIT
