ALSContext

JSON →
library 0.0.3 ·javascript
verified Jun 7, 2026

ALSContext is a Node.js library providing continuation-local storage (CLS) using AsyncLocalStorage with a fallback to a modified cls-hooked for older Node versions (8.12.0+). Current stable version 0.0.3 uses Node's built-in AsyncLocalStorage when available (>=12.17.0 or >=13.10.0) and a polyfill for older versions. It offers a consistent API for context propagation across async callbacks, with flat key-value operations and support for nested contexts. Unlike cls-hooked, nested run() calls create independent child contexts. It includes both a default ALS class (auto-detect) and a CLS class (force polyfill). TypeScript definitions are included and the package is ESM-first but supports CommonJS via named exports.