{"categories":["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],"description":"Connect your Node.js/JavaScript application to a Redis database","duplicateOf":"head:data-ai-metadata","location":"body","title":"node-redis guide (JavaScript)","tableOfContents":{"sections":[{"id":"install","title":"Install"},{"id":"connect-and-test","title":"Connect and test"},{"id":"more-information","title":"More information"}]},"codeExamples":[]}
Connect your Node.js/JavaScript application to a Redis database
node-redis is the Redis client for Node.js/JavaScript.
The sections below explain how to install node-redis and connect your application
to a Redis database.
Note:
node-redis is the recommended client library for Node.js/JavaScript,
but we also support and document our older JavaScript client
ioredis. See
Migrate from ioredis
if you are interested in converting an existing ioredis project to node-redis.
node-redis requires a running Redis server. See here for Redis Open Source installation instructions.
You can also access Redis with an object-mapping client interface. See
RedisOM for Node.js
for more information.
To 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).
When you have finished using a connection, close it with client.quit().