All eyes on AI: 2026 predictions – The shifts that will shape your stack.

Read now

Tutorial

Getting Started with Node and Redis

February 25, 20268 minute read
Ajeet Raina
Ajeet Raina
Simon Prickett
Simon Prickett
TL;DR:
Install the redis npm package (node-redis) or ioredis, call createClient() to connect Node.js to Redis, then use set and get for basic operations. Both clients support modern async/await patterns and deliver sub-millisecond response times.

#What you'll learn

  • How to install and configure node-redis or ioredis
  • How to connect Node.js to a Redis server
  • How to run basic Redis commands (strings, sorted sets) from JavaScript
  • How node-redis and ioredis compare so you can choose the right Redis npm package
  • Where to go next with Express, Redis OM, and more

#Prerequisites

  • Node.js v18 or later (LTS recommended)
  • npm or yarn package manager
  • A running Redis server — follow the Redis quick start to set one up

#Introduction

Redis is an open source, in-memory, key-value data store most commonly used as a primary database, cache, message broker, and queue. Redis cache delivers sub-millisecond response times, enabling fast and powerful real-time applications in industries such as gaming, fintech, ad-tech, social media, healthcare, and IoT.
Redis is a great database for use with Node.js. Both Redis and Node share similar type conventions and threading models, which makes for a very predictable development experience. By pairing Node.js and Redis together you can achieve a scalable and productive development platform.
Redis has two primary Node.js clients which are node-redis and ioredis. Both are available through npm. We generally suggest using node-redis, as it has wide support for Redis modules, is easily extended, and is widely used. Check out a list of Redis clients that the community has built (search Node).

#How do I install node-redis?

Run the following command to install the Redis npm package:

#How do I connect to Redis from Node.js?

Use createClient() from the redis package to open a connection. The example below connects to Redis, sets and gets a string key, adds items to a sorted set, and iterates over the results:

#How do I use ioredis with Node.js?

#Step 1. Install ioredis using npm (or yarn)

#Step 2. Write your application code

#node-redis vs ioredis: which should I use?

Featurenode-redisioredis
Redis module supportFull support (RediSearch, RedisJSON, etc.)Limited
API styleAsync/await with client.connect()Auto-connect on instantiation
Cluster supportYesYes
Sentinel supportYesYes
Lua scriptingevalSha / evaldefineCommand helper
TypeScriptBuilt-in typesBuilt-in types
Maintained byRedis officialCommunity
Recommendation: Use node-redis if you need advanced Redis data structure support (Search, JSON, time series, probabilistic, vectors) or want the officially maintained Redis JavaScript client.

#Example projects

#Hacker News Clone in Node.js

Hacker News Clone project illustration built with Next.js and Redis
A Hacker News Clone project built in Next.js, Node.js, and Express based on Search and JSON.

#Shopping Cart application in Node.js

Shopping Cart application illustration showing Node.js and Redis integration for e-commerce
Shopping Cart app in Node.js module functionalities.

#More developer resources

#Sample code

Basic Redis Caching — This application calls the GitHub API and caches the results into Redis.
Redis Rate-Limiting — This is a very simple app that demonstrates rate-limiting feature using Redis.
Notifications with WebSocket, Vue & Redis — This project allows you to push notifications in a Vue application from a Redis PUBLISH using WebSockets.

#Technical articles & videos

#Redis University

Build full-fledged Redis applications with Node.js and Express.

#Next steps