{
  "schema_version": 2,
  "id": "develop/clients/nodejs",
  "title": "node-redis guide (JavaScript)",
  "url": "https://redis.io/docs/latest/develop/clients/nodejs/",
  "summary": "Connect your Node.js/JavaScript application to a Redis database",
  "aliases": [
    "/develop/connect/clients/nodejs",
    "/connect/clients/nodejs/",
    "/clients/nodejs/",
    "/develop/clients/node-redis",
    "/develop/clients/javascript"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-10-12T14:48:04+01:00",
  "children": [
    {
      "id": "develop/clients/nodejs/connect",
      "summary": "Connect your Node.js application to a Redis database",
      "title": "Connect to the server",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/connect/"
    },
    {
      "id": "develop/clients/nodejs/amr",
      "summary": "Learn how to authenticate to an Azure Managed Redis (AMR) database",
      "title": "Connect to Azure Managed Redis",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/amr/"
    },
    {
      "id": "develop/clients/nodejs/queryjson",
      "summary": "Learn how to use Redis Search with JSON and hash documents.",
      "title": "Index and query documents",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/queryjson/"
    },
    {
      "id": "develop/clients/nodejs/vecsearch",
      "summary": "Learn how to index and query vector embeddings with Redis",
      "title": "Index and query vectors",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/vecsearch/"
    },
    {
      "id": "develop/clients/nodejs/vecsets",
      "summary": "Index and query embeddings with Redis vector sets",
      "title": "Vector set embeddings",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/vecsets/"
    },
    {
      "id": "develop/clients/nodejs/transpipe",
      "summary": "Learn how to use Redis pipelines and transactions",
      "title": "Pipelines and transactions",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/transpipe/"
    },
    {
      "id": "develop/clients/nodejs/prob",
      "summary": "Learn how to use approximate calculations with Redis.",
      "title": "Probabilistic data types",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/prob/"
    },
    {
      "id": "develop/clients/nodejs/error-handling",
      "summary": "Learn how to handle errors when using node-redis.",
      "title": "Error handling",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/error-handling/"
    },
    {
      "id": "develop/clients/nodejs/produsage",
      "summary": "Get your Node.js app ready for production",
      "title": "Production usage",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/produsage/"
    },
    {
      "id": "develop/clients/nodejs/migration",
      "summary": "Discover the differences between `ioredis` and `node-redis`.",
      "title": "Migrate from ioredis",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/migration/"
    },
    {
      "id": "develop/clients/nodejs/observability",
      "summary": "Monitor your client's activity for optimization and debugging.",
      "title": "Observability",
      "url": "https://redis.io/docs/latest/develop/clients/nodejs/observability/"
    }
  ],
  "page_type": "content",
  "content_hash": "0bea12547084779997122e3d3e5b73cd7dfa399eb82d32d30fdc262efea02745",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "[`node-redis`](https://github.com/redis/node-redis) is the Redis client for Node.js/JavaScript.\nThe sections below explain how to install `node-redis` and connect your application\nto a Redis database.\n\n> [!NOTE]\n> node-redis is the recommended client library for Node.js/JavaScript,\n> but we also support and document our older JavaScript client\n> [`ioredis`](https://redis.io/docs/latest/develop/clients/ioredis). See\n> [Migrate from ioredis](https://redis.io/docs/latest/develop/clients/nodejs/migration)\n> if you are interested in converting an existing `ioredis` project to `node-redis`.\n\n`node-redis` requires a running Redis server. See [here](https://redis.io/docs/latest/operate/oss_and_stack/install) for Redis Open Source installation instructions.\n\nYou can also access Redis with an object-mapping client interface. See\n[RedisOM for Node.js](https://redis.io/docs/latest/integrate/redisom-for-node-js)\nfor more information."
    },
    {
      "id": "install",
      "title": "Install",
      "role": "setup",
      "text": "To install node-redis, run:\n\n[code example]"
    },
    {
      "id": "connect-and-test",
      "title": "Connect and test",
      "role": "content",
      "text": "Connect to localhost on port 6379.\n\nFoundational: Create a client connection to a Redis server using node-redis\n\n[code example]\n\n\n\nStore and retrieve a simple string.\n\nFoundational: Set and retrieve string values using SET and GET commands\n\n[code example]\n\n\n\nStore and retrieve a map.\n\nFoundational: Store and retrieve hash data structures using HSET and HGET commands\n\n[code example]\n\n\n\nTo connect to a different host or port, use a connection URL:\n\n[code example]\n\n> [!NOTE]\n> node-redis supports [connection URLs](https://redis.io/docs/latest/develop/clients/connection-urls#node-redis-javascript) through the `url` option of `createClient()`.\n> A URL can set the host, port, credentials, database, and whether to use TLS,\n> so you can use one instead of passing those options separately.\n\nTo check if the client is connected and ready to send commands, use `client.isReady`, which returns a Boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example, when the client is still connecting or reconnecting after a network error).\n\nWhen you have finished using a connection, close it with `client.quit()`.\n\nFoundational: Close a Redis client connection using the quit() method\n\n[code example]"
    },
    {
      "id": "more-information",
      "title": "More information",
      "role": "content",
      "text": "The [`node-redis` website](https://redis.js.org/) has more examples.\nThe [Github repository](https://github.com/redis/node-redis) also has useful\ninformation, including a guide to the\n[connection configuration options](https://github.com/redis/node-redis/blob/master/docs/client-configuration.md) you can use.\n\nSee also the other pages in this section for more information and examples:"
    }
  ],
  "examples": [
    {
      "id": "install-ex0",
      "language": "bash",
      "code": "npm install redis",
      "section_id": "install"
    },
    {
      "id": "connect-and-test-ex0",
      "language": "javascript",
      "code": "import { createClient } from 'redis';\n\nconst client = createClient();\n\nclient.on('error', err => console.log('Redis Client Error', err));\n\nawait client.connect();",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex1",
      "language": "javascript",
      "code": "await client.set('key', 'value');\nconst value = await client.get('key');\nconsole.log(value);",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex2",
      "language": "javascript",
      "code": "await client.hSet('user-session:123', {\n    name: 'John',\n    surname: 'Smith',\n    company: 'Redis',\n    age: 29\n})\n\nlet userSession = await client.hGetAll('user-session:123');\nconsole.log(JSON.stringify(userSession, null, 2));",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex3",
      "language": "js",
      "code": "createClient({\n  url: 'redis://alice:foobared@awesome.redis.server:6380'\n});",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex4",
      "language": "javascript",
      "code": "await client.quit();",
      "section_id": "connect-and-test"
    }
  ]
}
