Lesson 18 / 20

Redis in a Node App

Connect to Redis from Node.js with the official redis package and cache values using async commands.

By · 15 years in web development · Updated 1 Oct 2026

Install the client

The official redis package works well for most Node apps.

npm install redis

Connect & use it

The client mirrors Redis commands as async methods, so caching a value looks almost like the CLI.

import { createClient } from 'redis';

const client = createClient({ url: 'redis://localhost:6379' });
await client.connect();

await client.set('greeting', 'hello', { EX: 60 });
const value = await client.get('greeting');
console.log(value); // 'hello'