A lightweight, high-performance Redis-backed leaderboard library for Node.js. Version 2.2.3 is the latest stable release, with active development. It provides a clean Promise-based API with full TypeScript support, leveraging ioredis pipelining and Lua scripts to guarantee at most one Redis trip per function call. Key differentiators: support for periodic/daily/weekly/monthly leaderboards, combining multiple leaderboards into a matrix, and the ability to use any existing Redis sorted set as a drop-in leaderboard. Unopinionated and well-tested with 100% code coverage.
npm install redis-rankNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Redis client, initializes a leaderboard, adds three players with scores, retrieves the top two, and fetches a player's rank.
Upgrade ioredis to >= 5.0.0, or use redis-rank < 2.2.0 (e.g., 2.1.2) with ioredis v4.
Use the PeriodicLeaderboard class for periodic leaderboards instead of passing a 'periodic' option.
Check Redis server version: redis-server --version, upgrade if below 2.6.12.
Add 1 to the result if you need 1-indexed rank. E.g., const rank = (await leaderboard.rank('player')) + 1;Ensure your Redis sorted set key is correctly specified; the library will not create a key until a write operation occurs.
Use correct named import: import { Leaderboard } from 'redis-rank'. Then instantiate: const lb = new Leaderboard(client, 'key');Start Redis server with: redis-server. Or modify connection options to point to a running instance.
Use destructured require: const { Leaderboard } = require('redis-rank');Run: npm install redis-rank ioredis