{
  "schema_version": 2,
  "id": "develop/clients/ioredis",
  "title": "ioredis guide (JavaScript)",
  "url": "https://redis.io/docs/latest/develop/clients/ioredis/",
  "summary": "Connect your Node.js/JavaScript application to a Redis database",
  "aliases": [
    "/connect/clients/ioredis/",
    "/clients/ioredis/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-09T11:51:21+01:00",
  "children": [
    {
      "id": "develop/clients/ioredis/connect",
      "summary": "Connect your Python application to a Redis database",
      "title": "Connect to the server",
      "url": "https://redis.io/docs/latest/develop/clients/ioredis/connect/"
    }
  ],
  "page_type": "content",
  "content_hash": "30fd5303d3dd715451ff77ea5d546c8ca00a0d26aa16cc3417c000932a66029d",
  "sections": [
    {
      "id": "install",
      "title": "Install",
      "role": "setup",
      "text": "To install `ioredis`, run:\n\n[code example]"
    },
    {
      "id": "connect-and-test",
      "title": "Connect and test",
      "role": "content",
      "text": "Connect to localhost on port 6379. \n\n**Available in:** JavaScript (Node.js)\n\n##### JavaScript (Node.js)\n\n[code example]\n\n\n\nStore and retrieve a simple string.\n\n**Available in:** JavaScript (Node.js)\n\n##### JavaScript (Node.js)\n\n[code example]\n\n\n\nStore and retrieve a map.\n\n**Available in:** JavaScript (Node.js)\n\n##### JavaScript (Node.js)\n\n[code example]\n\n\n\nWhen you have finished using a connection, close it with `client.quit()`.\n\n**Available in:** JavaScript (Node.js)\n\n##### JavaScript (Node.js)\n\n[code example]"
    },
    {
      "id": "more-information",
      "title": "More information",
      "role": "content",
      "text": "The [Github repository](https://github.com/redis/ioredis) has useful\ninformation, including [API docs](https://redis.github.io/ioredis/index.html)\nand a set of [code examples](https://github.com/redis/ioredis/tree/main/examples)."
    }
  ],
  "examples": [
    {
      "id": "install-ex0",
      "language": "bash",
      "code": "npm install ioredis",
      "section_id": "install"
    },
    {
      "id": "connect-and-test-ex0",
      "language": "javascript",
      "code": "import { Redis } from 'ioredis';\n\nconst redis = new Redis();",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex1",
      "language": "javascript",
      "code": "await redis.set('key', 'value');\nconst value = await redis.get('key');\nconsole.log(value); // >>> value",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex2",
      "language": "javascript",
      "code": "await redis.hset('user-session:123', {\n    name: 'John',\n    surname: 'Smith',\n    company: 'Redis',\n    age: 29\n});\n\nconst userSession = await redis.hgetall('user-session:123');\nconsole.log(JSON.stringify(userSession, null, 2));\n/* >>>\n{\n  \"surname\": \"Smith\",\n  \"name\": \"John\",\n  \"company\": \"Redis\",\n  \"age\": \"29\"\n}\n */",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex3",
      "language": "javascript",
      "code": "redis.disconnect();",
      "section_id": "connect-and-test"
    }
  ]
}
