# RESP3 Support Node Redis v5 adds support for [RESP3](https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md), the new Redis serialization protocol. RESP3 offers richer data types and improved type handling compared to RESP2. To use RESP3, specify it when creating your client: ```javascript import { createClient } from 'redis'; const client = createClient({ RESP: 3 }); ``` ## Type Mapping With RESP3, you can leverage the protocol's richer type system. You can customize how different Redis types are represented in JavaScript using type mapping: ```javascript import { createClient, RESP_TYPES } from 'redis'; // By default await client.hGetAll('key'); // Record // Use Map instead of plain object await client.withTypeMapping({ [RESP_TYPES.MAP]: Map }).hGetAll('key'); // Map // Use both Map and Buffer await client.withTypeMapping({ [RESP_TYPES.MAP]: Map, [RESP_TYPES.BLOB_STRING]: Buffer }).hGetAll('key'); // Map ``` This replaces the previous approach of using `commandOptions({ returnBuffers: true })` in v4. ## PubSub in RESP3 RESP3 uses a different mechanism for handling Pub/Sub messages. Instead of modifying the `onReply` handler as in RESP2, RESP3 provides a dedicated `onPush` handler. When using RESP3, the client automatically uses this more efficient push notification system. ## Known Limitations ### Unstable Module Commands Some Redis module commands have unstable RESP3 transformations. These commands will throw an error when used with RESP3 unless you explicitly opt in to using them by setting `unstableResp3: true` in your client configuration: ```javascript const client = createClient({ RESP: 3, unstableResp3: true }); ``` The following commands have unstable RESP3 implementations: 1. **Stream Commands**: - `XREAD` and `XREADGROUP` - The response format differs between RESP2 and RESP3 2. **Search Commands (RediSearch)**: - `FT.AGGREGATE` - `FT.AGGREGATE_WITHCURSOR` - `FT.CURSOR_READ` - `FT.INFO` - `FT.PROFILE_AGGREGATE` - `FT.PROFILE_SEARCH` - `FT.SEARCH` - `FT.SEARCH_NOCONTENT` - `FT.SPELLCHECK` 3. **Time Series Commands**: - `TS.INFO` - `TS.INFO_DEBUG` If you need to use these commands with RESP3, be aware that the response format might change in future versions. # Sentinel Support [Sentinel](./sentinel.md) # `multi.exec<'typed'>` / `multi.execTyped` We have introduced the ability to perform a "typed" `MULTI`/`EXEC` transaction. Rather than returning `Array`, a transaction invoked with `.exec<'typed'>` will return types appropriate to the commands in the transaction where possible: ```javascript const multi = client.multi().ping(); await multi.exec(); // Array await multi.exec<'typed'>(); // [string] await multi.execTyped(); // [string] ```