# @wendellhu/redi

> A dependency library for TypeScript and JavaScript, along with a binding for React.

Latest version **1.1.3** (published 2026-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wendellhu/redi
pnpm add @wendellhu/redi
yarn add @wendellhu/redi
bun add @wendellhu/redi
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2026-09-11 |
| First published | 2021-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 588.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 173 |
| Author | Evan<wzhudev@gmail.com> |
| Maintainers | wendellhu95 |

## Links

- npm: https://www.npmjs.com/package/@wendellhu/redi
- Repository: https://github.com/wzhudev/redi
- npm.io page: https://npm.io/package/@wendellhu/redi

## Recent versions

- 1.1.3 (latest) — 2026-09-11
- 0.6.1-hotfix.0 (beta) — 2023-01-30
- 1.1.2 — 2026-06-12
- 1.1.1 — 2026-01-07
- 1.1.0 — 2025-12-29
- 1.0.1 — 2025-09-08
- 1.0.0 — 2025-07-14
- 1.0.0-beta.1 — 2025-07-12
- 1.0.0-beta.0 — 2025-07-12
- 0.19.2 — 2025-07-08
- 0.19.1 — 2025-07-08
- 0.19.0 — 2025-07-08
- 0.18.3 — 2025-04-28
- 0.18.2 — 2025-04-28
- 0.18.1 — 2025-04-27
- … 56 more at https://npm.io/package/@wendellhu/redi/versions

## README

# redi

<p className="flex h-6">
  <img
    alt="stars"
    src="https://badgen.net/github/stars/wzhudev/redi"
    style={{ display: "inline-block", marginRight: "0.5rem" }}
  />
  <img
    alt="downloads"
    src="https://badgen.net/npm/dw/@wendellhu/redi"
    style={{ display: "inline-block", marginRight: "0.5rem" }}
  />
  <img
    alt="license"
    src="https://badgen.net/github/license/wzhudev/redi"
    style={{ display: "inline-block", marginRight: "0.5rem" }}
  />
  <img
    alt="coverage"
    src="https://img.shields.io/codecov/c/github/wzhudev/redi.svg"
    style={{ display: "inline-block" }}
  />
</p>

**redi** (pronounced 'ready') is a lightweight dependency injection library for TypeScript and JavaScript, with React bindings included.

## Why redi?

| Feature                 | Description                                     |
| ----------------------- | ----------------------------------------------- |
| 🪶 **Lightweight**      | Zero dependencies, small bundle size            |
| 🔧 **esbuild friendly** | No `emitDecoratorMetadata` required             |
| 📦 **Feature-rich**     | Class, value, factory, async injection and more |
| ⚛️ **React ready**      | Built-in hooks for React integration            |
| ✅ **Well tested**      | 100% code coverage                              |

## Quick Start

```bash npm2yarn
npm install @wendellhu/redi
```

```ts
import { Inject, Injector } from '@wendellhu/redi';

class AuthService {
  getCurrentUserInfo(): UserInfo {
    /* ... */
  }
}

class FileListService {
  constructor(@Inject(AuthService) private authService: AuthService) {}

  getUserFiles(): Promise<Files> {
    const user = this.authService.getCurrentUserInfo();
    // ...
  }
}

const injector = new Injector([[AuthService], [FileListService]]);
const fileList = injector.get(FileListService);
```

**[Getting started](https://redi.wzhu.dev/docs/introduction)**.

## Features

- **[Dependency Items](https://redi.wzhu.dev/docs/item)**: Class `{ useClass }`, Value `{ useValue }`, Factory `{ useFactory }`, Async `{ useAsync }`
- **[Interface Injection](https://redi.wzhu.dev/docs/identifier)**: Use `createIdentifier` for interface-based injection
- **[Lazy Instantiation](https://redi.wzhu.dev/docs/item)**: Defer creation with `{ lazy: true }`
- **[Hierarchy Injection](https://redi.wzhu.dev/docs/hierarchy)**: Parent-child injectors with `@Self()` and `@SkipSelf()`
- **[Optional & Many](https://redi.wzhu.dev/docs/declare-dependency)**: `@Optional()` and `@Many()` decorators
- **[React Integration](https://redi.wzhu.dev/docs/react)**: `useDependency`, `connectDependencies` and more hooks
- **[RxJS Support](https://redi.wzhu.dev/docs/react)**: `useObservable` and `useUpdateBinder` for reactive programming

## Who's Using redi?

- [Univer](https://github.com/dream-num/univer)
- ByteDance

## Links

- [Demo TodoMVC](https://wzhudev.github.io/redi-todomvc/) ([source](https://github.com/wzhudev/redi-todomvc))
- [Starter Template](https://github.com/wzhudev/redi-starter)
- [Contributing Guide](https://github.com/wzhudev/redi/blob/main/CONTRIBUTING.md)

## License

MIT. Copyright 2021-present Wenzhao Hu.

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