@cero-base/cero

中文文档
2.12.0发布于 2026/11/09Apache-2.0TypeScriptES Module近 30 天下载 2106

The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.

原始使用文档
文档目录3 节
  1. Docs
  2. Exports
  3. License

@cero-base/cero

[!IMPORTANT] This project is experimental. The API is subject to change and may break at any time.

Describe your data. Cero stores it on the device, syncs it across your devices and shares it with the people you invite. No server.

Cero is the SDK apps use, one of the two Cero Base packages, on the Pear stack by Holepunch. The other, Core (@cero-base/core), holds the primitives Cero is built from.

npm install @cero-base/cero

A Cero app is three files.

// schema.js
import { cero, t } from '@cero-base/cero'

export const schema = cero.schema({
  notes: t.collection({ title: t.string, body: t.string }),
  room: { messages: t.collection({ text: t.string }) }
})
// build.js, run once and after every schema change
import { build } from '@cero-base/cero/build'
import { schema } from './schema.js'

await build('./spec', schema)
// index.js
import { cero } from '@cero-base/cero'
import { spec } from './spec/index.js'

const me = await cero('./data', spec)
await cero.put(me.notes, { title: 'first', body: 'hello' })

const room = await cero.open(me.room, { name: 'general' })
console.log(await cero.invite(room)) // give this to a friend

Your friend, on their own machine, with the same three files:

// index.js
import { cero } from '@cero-base/cero'
import { spec } from './spec/index.js'

const me = await cero('./data', spec)
const invite = '…' // the string you gave them
const room = await cero.open(me.room, { invite })
for await (const { data } of cero.watch(room.messages)) console.log(data)

That is a working, encrypted, offline-first, peer-to-peer app. Your phrase, await cero.phrase(me), opens the same identity on any other device.

Docs

Exports

SubpathWhat it gives you
@cero-base/cerocero, t, schema, restore, peek, the 24 operators, Handle, Ref, Local
@cero-base/cero/buildbuild(specDir, schema, opts)
@cero-base/cero/serverserve(ipc, spec, opts) and Server, the worker that owns the data
@cero-base/cero/clientcero(ipc, spec) (also connect), Client, restore, t, schema and every operator but before, after and tx, for a UI process
@cero-base/cero/extensionsprofileSync, handleSync, bundled, extensionsOf, and a light cero with t, schema and the operators, for extension modules

The 24 operators, each also on the facade as cero.put and so on: put, set, get, del, watch, call, open, tx, invite, revoke, rotate, accept, deny, leave, close, cancel, suspend, resume, activate, deactivate, phrase, nearby, before, after.

Built on the Pear stack: Hypercore, Autobee, HyperDB, Hyperblobs, Hyperswarm, blind-peering and Bare. Runs on Node and Bare, with TypeScript declarations.

License

Apache-2.0

版本与发布记录

@cero-base/cero 共发布 78 个版本,首次发布于 2026/05/29;过去 12 个月发布了 78 个版本。

版本发布日期距今
2.12.0latest2026/11/09今天
2.11.02026/11/09今天
2.10.02026/11/027 天前
2.9.02026/10/3010 天前
2.8.02026/10/3011 天前
2.7.02026/10/2713 天前

关于 @cero-base/cero 的常见问题

@cero-base/cero 是什么?

The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.

如何安装 @cero-base/cero?

在项目目录运行 npm install @cero-base/cero,或使用 pnpm add / yarn add / bun add。

@cero-base/cero 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cero-base/cero 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cero-base/cero 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cero-base/cero 可以商用吗?

@cero-base/cero 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cero-base/cero 的下载量有多少?

根据 npm 官方下载统计,@cero-base/cero 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,106 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cero-base/cero 还在维护吗?

最新版本 2.12.0 发布于 2026/11/09(今天);至今共发布 78 个版本,其中过去 12 个月发布了 78 个;首次发布于 2026/05/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。