stable
yjs
Yjs Y.Doc interop — yjsCollection() stores CRDT state encrypted at rest for collaborative rich-text fields; the storage backend never sees plaintext.
@noy-db/in-yjs·pnpm add @noy-db/hub @noy-db/in-yjs yjsYjsY.Docinterop for noy-db — collaborative rich-text editing, encrypted at rest.
What it does
yjsCollection(compartment, name, { yFields }) wraps a collection whose
named fields hold Yjs CRDT state, described via yText(), yMap(), or
yArray() field descriptors. getYDoc(id) / putYDoc(id, doc) round-trip
a Y.Doc through encryption — the CRDT update log is encrypted before it
reaches any to-* storage backend, so collaborative editing and offline
merging both happen without the store ever seeing plaintext.
Usage
import { yjsCollection, yText } from '@noy-db/in-yjs'
const notes = yjsCollection(comp, 'notes', { yFields: { body: yText() } })
const doc = await notes.getYDoc('note-1')
doc.getText('body').insert(0, 'Hello world')
await notes.putYDoc('note-1', doc)
See also
- in-* family
- ai · rest — the other protocol/runtime bindings in the family