Packages
Replication API
The optional /sync entry of the P2P library: data, files and protection status.
Verified 16 October 2026
syncPack replicates Hypercores, Hyperbees and Hyperdrives and keeps seeding registered resources after the owner disconnects. It shares the P2P package's connection lifecycle. These reference pages describe the alpha.2 candidate; alpha.1 is already published.
import { syncPack } from '@unstoppable-stack/p2p/sync'
// Add this pack to createNode({ capabilities: [...] }).
const sync = syncPack({ store: appStore })
// A host without a store can use syncPack({ storage: './.replicas' }).
// After pairing with the host and receiving sync grants:
await peer.call('sync', 'manifest.replace', {
manifest: { schemaVersion: 1, resources: [
{ id: 'notes', kind: 'hyperbee', key: dataCoreKey,
name: 'Notes', protection: { mode: 'mirror' } }
] }
})
const status = await peer.call('sync', 'status')
const { bytes } = await peer.call('sync', 'usage')Methods and ownership
- manifest.replace replaces the caller's complete resource set; omitted resources are unregistered. An empty list removes all its registrations. It is not a merge or disk purge.
- status reports only the calling peer's cores, drives and protection state. usage reports its logical replicated bytes, not physical host disk use.
- pause and resume act on the caller's resource set and persist across restart. Their scope is discovery-and-mirroring; existing replication channels may still transfer data. Personal Node uses an admit(ownerKey) callback for quota checks.
- peek.core and peek.drive are bounded diagnostics, excluded from default grants. They do not provide generic file downloads or database queries.
- Ownership follows the authenticated peer key. Two installations of one app have separate resource sets. Persisted manifests resume replication after host restart.
Manifest and protection contract
Version 1 manifests accept up to 128 resources with unique ids and 32-byte hex keys, supported kind, name and optional bounded string metadata. Protection defaults to metadata-only. mirror requests a full copy of the observed core length or drive version. Only locally checked checkpoints become protected; this does not promise future writes or independently tested recovery.
Restore remains a separate contract
Apps write to their local stores and drives first. Ordinary replication can retrieve data when its keys and availability are known. Dedicated file reads/ranges, selective path sync, full encrypted archives, identity recovery and purge controls are not built-in services.