{"id":28472,"library":"y-memory","title":"y-memory","description":"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.","status":"active","version":"8.0.9","language":"javascript","source_language":"en","source_url":"https://github.com/y-js/y-memory","tags":["javascript","Yjs","OT","Collaboration","Synchronization","ShareJS","Coweb","Concurrency"],"install":[{"cmd":"npm install y-memory","lang":"bash","label":"npm"},{"cmd":"yarn add y-memory","lang":"bash","label":"yarn"},{"cmd":"pnpm add y-memory","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for operation","package":"yjs","optional":false}],"imports":[{"note":"y-memory is a side-effect module that registers itself as a Yjs db adapter; no named export needed.","wrong":"const memory = require('y-memory')","symbol":"y-memory","correct":"import 'y-memory'"},{"note":"Yjs mainly supports ESM; CommonJS might cause issues with bundlers.","wrong":"const Y = require('yjs')","symbol":"Yjs","correct":"import * as Y from 'yjs'"},{"note":"Yjs is initialized via a function call to Y(), not as a constructor.","wrong":"new Yjs({ db: { name: 'memory' } })","symbol":"Y","correct":"Y({ db: { name: 'memory' } })"}],"quickstart":{"code":"// Install: npm install yjs y-memory\nimport * as Y from 'yjs';\nimport 'y-memory';\n\n// Initialize Yjs with memory adapter\nconst y = new Y.Doc();\nconst yarray = y.getArray('myarray');\nyarray.insert(0, ['hello']);\n\n// Or use the legacy Y() constructor (deprecated but still works)\n// Y({ db: { name: 'memory' } }).then(y => { ... });\n\nconsole.log(yarray.toArray()); // ['hello']","lang":"javascript","description":"Shows how to import y-memory and use it with Yjs to create an in-memory document and manipulate a shared array."},"warnings":[{"fix":"Use `new Y.Doc()` and manage persistence separately.","message":"The Y() constructor with db adapter config is deprecated; use Y.Doc() directly in Yjs v13+.","severity":"deprecated","affected_versions":">=13.0.0"},{"fix":"Use a persistent adapter like y-indexeddb or y-leveldb for permanent storage.","message":"Data is lost when page is refreshed; memory adapter does not persist.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure Yjs version is >=9.0.0 and <14.0.0.","message":"y-memory v8 only works with Yjs >=9.0.0 <14.0.0; older versions incompatible.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Use `npm install y-memory` instead.","message":"Bower installation is deprecated; use npm or yarn.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `npm install y-memory` and add `import 'y-memory'` at the top of your file.","cause":"Missing import or npm install.","error":"Error: Cannot find module 'y-memory'"},{"fix":"Use `new Y.Doc()` instead of `Y({...})`.","cause":"Trying to use Y() constructor in Yjs v13+ where it's removed.","error":"TypeError: Y is not a function"},{"fix":"Update Yjs to version 9.0.0-13.x.x with `npm install yjs@^13.0.0`.","cause":"Incompatible Yjs version.","error":"Error: Yjs version must be between 9.0.0 and 14.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}