{"id":18358,"library":"express-slow-down","title":"Express Slow Down","description":"Basic rate-limiting middleware for Express that slows down responses rather than blocking them outright. Current stable version is 3.1.0, released as part of the express-rate-limit ecosystem. It is built on top of express-rate-limit and uses its stores, providing a familiar API for slowing repeated requests. Key differentiator: it delays requests after a threshold instead of rejecting them, making it suitable for public API endpoints where gradual throttling is preferred over hard blocks. Requires Node >= 16 and Express 4/5. Ships TypeScript types, supports ESM and CJS, and is actively maintained.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/express-rate-limit/express-slow-down","tags":["javascript","express-rate-limit","express","rate","limit","ratelimit","rate-limit","middleware","ip","typescript"],"install":[{"cmd":"npm install express-slow-down","lang":"bash","label":"npm"},{"cmd":"yarn add express-slow-down","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-slow-down","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the middleware works as an Express middleware and requires Express 4 or 5.","package":"express","optional":false}],"imports":[{"note":"This package exports a named export 'slowDown', not a default export. The wrong pattern is common when migrating from older versions or confusing with similar libraries.","wrong":"import slowDown from 'express-slow-down'","symbol":"slowDown","correct":"import { slowDown } from 'express-slow-down'"},{"note":"In CommonJS, destructure the named export. Doing require('express-slow-down') directly yields an object with the named export.","wrong":"const slowDown = require('express-slow-down')","symbol":"slowDown","correct":"const { slowDown } = require('express-slow-down')"},{"note":"The exported function is lowercased 'slowDown'. TypeScript types are included, but the export name is case-sensitive.","wrong":"import { SlowDown } from 'express-slow-down' (wrong case)","symbol":"slowDown (TypeScript)","correct":"import { slowDown } from 'express-slow-down'"}],"quickstart":{"code":"import { slowDown } from 'express-slow-down';\nimport express from 'express';\n\nconst app = express();\n\nconst speedLimiter = slowDown({\n  windowMs: 15 * 60 * 1000, // 15 minutes\n  delayAfter: 5, // allow 5 requests per 15 minutes without delay\n  delayMs: (hits) => hits * 100, // add 100ms delay per hit after the 5th\n});\n\napp.use('/api', speedLimiter);\n\napp.listen(3000);","lang":"typescript","description":"Creates a speed limiter middleware that delays requests after 5 hits within 15 minutes, adding incremental delay."},"warnings":[{"fix":"Change `import slowDown from 'express-slow-down'` to `import { slowDown } from 'express-slow-down'`.","message":"Version 3.0.0 removed the default export; use named export 'slowDown' instead.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update `delayMs` to be a function returning the delay in ms, and ensure Node version >= 16.","message":"Version 2.0.0 dropped support for Node < 16 and changed the API from `delayMs` as a number to a function.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Create separate store instances: `const store1 = new MemcachedStore({ prefix: 'rl:' }); const store2 = new MemcachedStore({ prefix: 'sd:' });`","message":"When using both express-rate-limit and express-slow-down with the same external store, you must create two separate store instances with different prefixes to avoid double-counting.","severity":"gotcha","affected_versions":"*"},{"fix":"Use the 'skip' function with a custom check instead of 'skipFailedRequests'.","message":"The 'skipFailedRequests' option has been deprecated in favor of 'skip' function.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use named import: `import { slowDown } from 'express-slow-down'`","cause":"Trying to default-import the module, but version 3.x only provides named export 'slowDown'.","error":"import slowDown from 'express-slow-down';\n       ^^^^^^^^\nSyntaxError: The requested module 'express-slow-down' does not provide an export named 'default'"},{"fix":"Use: `const { slowDown } = require('express-slow-down')`","cause":"Using `require('express-slow-down')` and calling the result as a function, but it exports an object with 'slowDown' method.","error":"TypeError: slowDown is not a function"},{"fix":"Replace `delayMs: 1000` with `delayMs: (hits) => hits * 1000` or similar function.","cause":"Passing a static number for `delayMs` in version 2+, where it must be a function.","error":"Error: The 'delayMs' option must be a function that returns a number. Received number."},{"fix":"Use a store from express-rate-limit's compatible stores (e.g., rate-limit-memcached) or implement the Store interface.","cause":"Passing a plain object as a store without implementing all required methods.","error":"Error: The 'store' option must be an instance of a store that implements the 'Store' interface."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}