content/develop/clients/ioredis/_index.md
ioredis is a Redis client for Node.js/JavaScript.
The sections below explain how to install ioredis and connect your application
to a Redis database.
{{< note >}}Redis actively maintains and supports ioredis since it is in widespread use, but
for new projects, we recommend using our newer Node.js client
[node-redis]({{< relref "/develop/clients/nodejs" >}}). See
[Migrate from ioredis]({{< relref "/develop/clients/nodejs/migration" >}})
if you are interested in converting an existing ioredis project to node-redis.
{{< /note >}}
ioredis requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
To install ioredis, run:
npm install ioredis
Connect to localhost on port 6379.
{{< clients-example set="landing" step="connect" lang_filter="ioredis" >}} {{< /clients-example >}}
Store and retrieve a simple string.
{{< clients-example set="landing" step="set_get_string" lang_filter="ioredis" >}} {{< /clients-example >}}
Store and retrieve a map.
{{< clients-example set="landing" step="set_get_hash" lang_filter="ioredis" >}} {{< /clients-example >}}
When you have finished using a connection, close it with client.quit().
{{< clients-example set="landing" step="close" lang_filter="ioredis" >}} {{< /clients-example >}}
The Github repository has useful information, including API docs and a set of code examples.