Tutorial
Getting Started with Node and Redis
February 25, 20268 minute read
TL;DR:Install theredisnpm package (node-redis) orioredis, callcreateClient()to connect Node.js to Redis, then usesetandgetfor 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?
| Feature | node-redis | ioredis |
|---|---|---|
| Redis module support | Full support (RediSearch, RedisJSON, etc.) | Limited |
| API style | Async/await with client.connect() | Auto-connect on instantiation |
| Cluster support | Yes | Yes |
| Sentinel support | Yes | Yes |
| Lua scripting | evalSha / eval | defineCommand helper |
| TypeScript | Built-in types | Built-in types |
| Maintained by | Redis official | Community |
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

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 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 Rapid Tips: ioredis (YouTube)
Mapping Objects between Node and Redis (YouTube)
#Redis University
Build full-fledged Redis applications with Node.js and Express.
#Next steps
- Express + Redis OM for Node.js — Build a REST API in minutes using Express and Redis OM to map objects to Redis easily.
- Redis Caching Quick Start — Learn how to cache API responses with Redis and Node.js.
- Redis Rate-Limiting — Add rate limiting to your Node.js application using Redis.

