# asyncctx

> an asynchronous execution context for TypeScript/JavaScript

Latest version **2.1.7** (published 2026-08-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install asyncctx
pnpm add asyncctx
yarn add asyncctx
bun add asyncctx
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.7 |
| Published | 2026-08-16 |
| First published | 2016-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Guenter Sandner |
| Maintainers | gms1 |
| Keywords | typescript, asynchronous context, execution context, CLS, continuation local storage, async_hooks |

## Links

- npm: https://www.npmjs.com/package/asyncctx
- Repository: https://github.com/gms1/HomeOfThings
- Issues: https://github.com/gms1/HomeOfThings/issues
- npm.io page: https://npm.io/package/asyncctx

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.1.7 (latest) — 2026-08-16
- 2.1.6 — 2026-06-07
- 2.1.5 — 2026-03-19
- 2.1.4 — 2025-04-26
- 2.1.3 — 2024-12-22
- 2.1.2 — 2024-10-26
- 2.1.1 — 2023-12-19
- 2.1.0 — 2023-11-19
- 2.0.19 — 2022-04-18
- 2.0.18 — 2021-08-24
- 2.0.17 — 2021-08-18
- 2.0.16 — 2021-04-10
- 2.0.15 — 2021-01-14
- 2.0.14 — 2020-10-10
- 2.0.13 — 2020-05-17
- … 43 more at https://npm.io/package/asyncctx/versions

## README

[![npm version](https://badge.fury.io/js/asyncctx.svg)](https://badge.fury.io/js/asyncctx)
[![Build Workflow](https://github.com/gms1/HomeOfThings/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/gms1/HomeOfThings/actions/workflows/build.yml)
[![Coverage Status](https://codecov.io/gh/gms1/HomeOfThings/branch/master/graph/badge.svg?flag=asyncctx)](https://app.codecov.io/gh/gms1/HomeOfThings/tree/master/packages%2Fnode%2Fasyncctx)
[![DeepScan grade](https://deepscan.io/api/teams/439/projects/987/branches/1954/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=439&pid=987&bid=1954)
[![Known Vulnerabilities](https://snyk.io/test/github/gms1/HomeOfThings/badge.svg)](https://snyk.io/test/github/gms1/HomeOfThings)

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![License](https://img.shields.io/npm/l/asyncctx.svg?style=flat-square)](https://github.com/gms1/HomeOfThings/blob/master/packages/node/asyncctx/LICENSE)

# node-async-context (asyncctx)

This module allows you to create an asynchronous execution context for JavaScript or TypeScript

> NOTE: This module is based on [async_hooks](https://github.com/nodejs/node/blob/master/doc/api/async_hooks.md) an experimental built-in node.js module introduced in v8.0.0

## Deprecation

<!-- -->

> NOTE: This module is now deprecated in favour of [AsyncLocalStorage](https://nodejs.org/api/async_context.html#async_context_new_asynclocalstorage)
> which is available for nodejs >= 12

### quick start using AsyncLocalStorage

```Typescript
class ContinuationLocalStorage<T> extends AsyncLocalStorage<T> {
  public getContext(): T | undefined {
    return this.getStore();
  }
  public setContext(value: T): T {
    this.enterWith(value);
    return value;
  }
}
```

## Introduction

To give you an idea of how **asyncctx** is supposed to be used:

```TypeScript
import { ContinuationLocalStorage } from 'asyncctx';

class MyLocalStorage {
  value: number;
}

let cls = new ContinuationLocalStorage<MyLocalStorage>();
cls.setRootContext({ value: 1 });

process.nextTick(() => {
  let curr1 = cls.getContext(); // value is 1
  cls.setContext({ value: 2 }); // value should be 2 in the current execution context and below
  process.nextTick(() => {
    let curr2 = cls.getContext(); // value is 2
    cls.setContext({ value: 3 }); // value should be 3 in the current execution context and below
    process.nextTick(() => {
      let curr3 = cls.getContext(); // value is 3
    });
  });
  process.nextTick(() => {
    let curr4 = cls.getContext(); // value is 2
  });
});
```

## RELEASE NOTES

[CHANGELOG](./CHANGELOG.md)

## License

**node-async-context (asyncctx)** is licensed under the MIT License:
[LICENSE](./LICENSE)

---
_Source: https://npm.io/package/asyncctx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
