Registry / database / y-memory

y-memory

JSON →
library8.0.9jsnpmunverified

In-memory database adapter for Yjs, version 8.0.9. It provides a lightweight, ephemeral storage backend for collaborative editing with Yjs, discarding all data upon session end. Best for prototyping or stateless scenarios. Works in all browsers with fast access. Unlike persistent adapters (e.g., y-leveldb), it requires no external database setup. Released under MIT.

npm install y-memory
INSTALL
IMPORT
SIG · Y-MEMORY
Y
y-memory
databasejavascriptv8.0.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

y-memory
import 'y-memory'
const memory = require('y-memory')
y-memory is a side-effect module that registers itself as a Yjs db adapter; no named export needed.
Yjs
import * as Y from 'yjs'
const Y = require('yjs')
Yjs mainly supports ESM; CommonJS might cause issues with bundlers.
Y
Y({ db: { name: 'memory' } })
new Yjs({ db: { name: 'memory' } })
Yjs is initialized via a function call to Y(), not as a constructor.

Shows how to import y-memory and use it with Yjs to create an in-memory document and manipulate a shared array.

// Install: npm install yjs y-memory import * as Y from 'yjs'; import 'y-memory'; // Initialize Yjs with memory adapter const y = new Y.Doc(); const yarray = y.getArray('myarray'); yarray.insert(0, ['hello']); // Or use the legacy Y() constructor (deprecated but still works) // Y({ db: { name: 'memory' } }).then(y => { ... }); console.log(yarray.toArray()); // ['hello']
Debug
Known issues
deprecatedThe Y() constructor with db adapter config is deprecated; use Y.Doc() directly in Yjs v13+.
fix
Use `new Y.Doc()` and manage persistence separately.
affects: >=13.0.0
gotchaData is lost when page is refreshed; memory adapter does not persist.
fix
Use a persistent adapter like y-indexeddb or y-leveldb for permanent storage.
affects: >=0.1.0
breakingy-memory v8 only works with Yjs >=9.0.0 <14.0.0; older versions incompatible.
fix
Ensure Yjs version is >=9.0.0 and <14.0.0.
affects: >=8.0.0
deprecatedBower installation is deprecated; use npm or yarn.
fix
Use `npm install y-memory` instead.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'y-memory'
Missing import or npm install.
fix
Run `npm install y-memory` and add `import 'y-memory'` at the top of your file.
TypeError: Y is not a function
Trying to use Y() constructor in Yjs v13+ where it's removed.
fix
Use `new Y.Doc()` instead of `Y({...})`.
Error: Yjs version must be between 9.0.0 and 14.0.0
Incompatible Yjs version.
fix
Update Yjs to version 9.0.0-13.x.x with `npm install yjs@^13.0.0`.
Upgrade
Version history
8.0.9latest on npm
Audit
Dependencies
yjsrequiredpeer dependency required for operation
Agent activity
24 hits · last 30 days
node
20
Meta
1
OpenAI (training)
1
Resources
y-memory — npm install y-memory · libregistry