@swarm-keydb/client)npm install @swarm-keydb/client
import { createClient } from '@swarm-keydb/client';
const client = createClient({ wsUrl: 'ws://127.0.0.1:8765/' });
await client.connect();
await client.set('hello', 'world');
console.log(await client.get('hello'));
See also runnable example: examples/js/quickstart.js.
wsUrl (default ws://127.0.0.1:8765/): primary WebSocket endpointhttpUrl (default http://127.0.0.1:8080): REST fallback endpointpassword: sends AUTH automatically after connectreconnect + reconnectBaseDelayMs + reconnectMaxDelayMs: exponential backoff reconnectrequestTimeoutMs: per-command timeouthttpFallback: use HTTP fallback for get/set when WebSocket is unavailableThe client negotiates RESP3 automatically by sending HELLO 3 after connect.
get, set, del, exists, expire, ttl, keys, mget, mset, incr, decr, incrbyhget, hset, hgetall, hdel, hkeys, hvalslpush, rpush, lrange, llen, lpop, rpopsadd, smembers, sismember, srem, scardzadd, zrange, zscore, zrank, zremsubscribe, unsubscribe, psubscribe, punsubscribe, publishxadd, xrange, xread, xlenCommon operations map directly:
redis.get(key) -> client.get(key)redis.set(key, value) -> client.set(key, value)redis.del(key) -> client.del(key)redis.subscribe(channel, cb) -> client.subscribe(channel, cb)redis.publish(channel, message) -> client.publish(channel, message)Differences:
HELLO 3 negotiation automatically.ws in Node.js environments).WebSocket and fetch APIs.eval/dynamic code execution is required by the SDK runtime.| Environment | Status | Notes |
|---|---|---|
| Node.js 20+ | ✅ Supported | Uses ws transport automatically |
| Modern browsers (Chromium/Firefox/WebKit) | ✅ Supported | Uses native WebSocket + fetch |
| RESP3 server negotiation | ✅ Supported | Sends HELLO 3 during connect handshake |
HTTP fallback (GET / SET) |
✅ Supported | Enabled by default when WebSocket is unavailable |