Continuation Local Storage (CLS) for Node.js based on async_hooks, providing context propagation across async calls. Version 1.0.7 is stable and works with Node >=8.0.0. It is an alternative to the deprecated domain module and offers nested contexts, Symbol keys to avoid collisions, and an await-compatible start() method (Node 12+). Unlike similar libraries like cls-hooked or async-hooks-context, node-cls focuses on a simple API with create, run, get, start, and exit methods. Release cadence is low; no recent updates.
npm install node-clsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a contextual namespace, setting a property, running a function that retrieves the context synchronously and asynchronously.
Place `require('node-cls')` as the first line of your application entry point.Order middlewares: app.use(bodyParser); app.use(cls.middleware);
Upgrade to Node 12+ or use a stable alternative like cls-hooked.
Use @types/node-cls if available, or declare module manually.
Use `import cls from 'node-cls'` or `const cls = require('node-cls')`.Ensure each context.run() completes or call context.exit() when using start().
Wrap code that needs context inside context.run() or await context.start().
No dependency data recorded yet.