Registry / database / y-redis

y-redis

JSON →
library1.0.3jsnpmunverified

Redis persistence adapter for Yjs, a CRDT-based collaborative editing framework. Current stable version 1.0.3, with irregular release cadence. Provides a Redis backend to persist Yjs documents, enabling durable storage and retrieval of shared data structures. Key differentiator: integrates seamlessly with Yjs's internal persistence API, allowing real-time collaboration with Redis as a storage layer. Supports automatic document recovery and synchronous writes. Requires Yjs ^13.0.2 as a peer dependency. Note: This package is labeled as work in progress and may have limited features or stability compared to other Yjs persistence adapters.

npm install y-redis
INSTALL
IMPORT
SIG · Y-REDIS
Y
y-redis
databasejavascriptv1.0.3
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.

yRedisPersistence
import { yRedisPersistence } from 'y-redis'
import yRedisPersistence from 'y-redis'
Named export in ESM; default import is incorrect.
configure
import { configure } from 'y-redis'
const { configure } = require('y-redis')
ESM-only since version 1.0; CJS require may fail if bundler does not handle ESM.

Shows how to initialize a Redis persistence adapter for a Yjs document, bind it, and retrieve persisted state. Includes environment variable for Redis URL.

import * as Y from 'yjs' import { configure } from 'y-redis' const doc = new Y.Doc() const persistence = configure({ redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379', docName: 'my-doc' }) // Bind persistence to doc persistence.bindDoc(doc) // Now doc is automatically persisted to Redis // To retrieve later: const doc2 = new Y.Doc() persistence.bindDoc(doc2) // doc2 will be synced with Redis data
Debug
Known issues
gotchay-redis is marked as 'work in progress' and may have limited features or stability. Not recommended for production use without thorough testing.
fix
Consider using y-leveldb or y-mongodb for more stable persistence.
affects: >=0.0.0
breakingVersion 1.0 switched from CommonJS to ESM-only exports. CJS require() will break in Node.js without proper bundler configuration.
fix
Use import statements or configure your bundler to handle ESM.
affects: >=1.0.0
deprecatedThe `setPersistence` function from previous versions (0.x) is removed in v1.0. Use `configure` and `bindDoc` instead.
fix
Migrate from `setPersistence(doc, adapter)` to `configure(options).bindDoc(doc)`.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/node_modules/y-redis/dist/index.mjs
CJS require() used with an ESM-only package in Node.js without bundler support.
fix
Use dynamic import: const { configure } = await import('y-redis') or switch to ESM in your project.
TypeError: yRedisPersistence is not a function
Using default import instead of named import for yRedisPersistence.
fix
Change import to: import { yRedisPersistence } from 'y-redis'
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
yjsrequiredPeer dependency required for document synchronization and CRDT operations.
Agent activity
29 hits · last 30 days
node
24
Meta
2
OpenAI (training)
1
Resources
y-redis — npm install y-redis · libregistry