Configuration Options

Complete reference for all hitlimit configuration options.

Basic Options

OptionTypeDefaultDescription
limitnumber100Maximum requests per window
windowstring | number'1m'Time window (e.g., '1m', '1h', '1d')
keyfunctionreq.ipFunction to extract rate limit key
storeStorememoryStore()Storage backend

Advanced Options

OptionTypeDefaultDescription
skipfunctionundefinedSkip rate limiting for certain requests
headersbooleantrueInclude rate limit headers
statusCodenumber429HTTP status when rate limited
responseobject | function-Custom response body

Full Example

hitlimit({
  limit: 100,
  window: '1m',
  key: (req) => req.headers['x-api-key'] || req.ip,
  store: sqliteStore({ path: './limits.db' }),
  skip: (req) => req.path === '/health',
  headers: true,
  statusCode: 429,
  response: { error: 'Too many requests' }
})