{"id":46407,"library":"socket.io-redis-adapter","title":"Socket.IO Redis Adapter","description":"Redis-based adapter for Socket.IO that enables broadcasting events between multiple Socket.IO server instances via Redis Pub/Sub. Version 8.4.6 (stable), maintained by the Socket.IO team. Ships TypeScript types. Requires socket.io-adapter ^2.4.0 peer dependency. Supports CommonJS, ES modules, and TypeScript. Key differentiator: uses two separate Redis clients (pub/sub) for reliability; supports both standard and sharded Pub/Sub (Redis 7.0+). Migration from legacy socket.io-redis package requires API changes.","status":"active","version":"8.4.6","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/sorilove/socket.io-redis-adapter","tags":["javascript","typescript"],"install":[{"cmd":"npm install socket.io-redis-adapter","lang":"bash","label":"npm"},{"cmd":"yarn add socket.io-redis-adapter","lang":"bash","label":"yarn"},{"cmd":"pnpm add socket.io-redis-adapter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for adapter interface","package":"socket.io-adapter","optional":true},{"reason":"Application must install a Redis client (e.g., ioredis or node-redis) to create pub/sub clients","package":"redis","optional":true}],"imports":[{"note":"Package renamed from 'socket.io-redis' to 'socket.io-redis-adapter' in v6. Always use the new name.","wrong":"const createAdapter = require('socket.io-redis'); // wrong package name","symbol":"createAdapter","correct":"import { createAdapter } from 'socket.io-redis-adapter'"},{"note":"Only named exports are provided. No default export.","wrong":"import RedisAdapter from 'socket.io-redis-adapter'; // default import does not exist","symbol":"RedisAdapter","correct":"import { RedisAdapter } from 'socket.io-redis-adapter'"}],"quickstart":{"code":"import { Server } from 'socket.io';\nimport { createClient } from 'redis';\nimport { createAdapter } from 'socket.io-redis-adapter';\n\nconst io = new Server();\nconst pubClient = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' });\nconst subClient = pubClient.duplicate();\n\nPromise.all([\n  pubClient.connect(),\n  subClient.connect()\n]).then(() => {\n  io.adapter(createAdapter(pubClient, subClient));\n  io.listen(3000);\n  console.log('Socket.IO server with Redis adapter listening on port 3000');\n});","lang":"typescript","description":"Create a Socket.IO server with Redis adapter using two Redis clients (pub/sub). Must call connect() for each client (redis@4+)."},"warnings":[{"fix":"Replace require('socket.io-redis') with require('socket.io-redis-adapter') and update imports to named export createAdapter.","message":"Package renamed from 'socket.io-redis' to 'socket.io-redis-adapter' in version 6.0.0. Old package deprecated.","severity":"breaking","affected_versions":"<6.0.0"},{"fix":"Add await pubClient.connect() and await subClient.connect() before calling io.adapter().","message":"redis@4+ requires explicit connect() calls. Not calling pubClient.connect()/subClient.connect() causes 'start' event to fail silently.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Always use pubClient.duplicate() to create a separate sub client.","message":"Using the same Redis client instance for both pub and sub leads to message deduplication issues and potential deadlocks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch from ioredis to redis package. If using ioredis, ensure compatibility via custom adapter options.","message":"Usage with ioredis client is deprecated. Prefer 'redis' package (node-redis) v4+.","severity":"deprecated","affected_versions":">=8.0.0"}],"env_vars":null,"search_vec":"'2.4.0':36 '7.0':62 '8.4.6':23 'adapt':3,7,35 'api':70 'base':6 'broadcast':12 'chang':71 'client':51 'commonj':40 'depend':38 'differenti':46 'enabl':11 'es':41 'event':13 'instanc':18 'javascript':72 'key':45 'legaci':65 'maintain':25 'migrat':63 'modul':42 'multipl':15 'packag':68 'peer':37 'pub/sub':21,52,60 'redi':2,5,20,50,61,67 'redis-bas':4 'reliabl':54 'requir':33,69 'separ':49 'server':17 'shard':59 'ship':30 'socket.io':1,9,16,28,34,66 'stabl':24 'standard':57 'support':39,55 'team':29 'two':48 'type':32 'typescript':31,44,73 'use':47 'version':22 'via':19","created_at":"2026-06-07T12:59:46.654654+00:00","updated_at":"2026-06-07T12:59:46.654654+00:00","problems":[{"fix":"npm uninstall socket.io-redis && npm install socket.io-redis-adapter && change imports to 'socket.io-redis-adapter'","cause":"Package renamed to 'socket.io-redis-adapter' but code still imports the old name.","error":"Error: Cannot find module 'socket.io-redis'"},{"fix":"Check Redis client version. For redis@3: don't call connect(). For redis@4: import { createClient } from 'redis' and call client.connect(). For ioredis: use new Redis() and don't call connect().","cause":"Using redis@3 (no need for connect()) or ioredis but calling connect() like redis@4. Or using redis@4 and not importing createClient correctly.","error":"TypeError: pubClient.connect is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sorilove/socket.io-redis-adapter#readme","github":"ssh://git@github.com/sorilove/socket.io-redis-adapter","docs":null,"changelog":null,"pypi":null,"npm":"socket.io-redis-adapter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}