Skip to Content

redi

starsdownloadslicensecoverage

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

Why redi?

FeatureDescription
🪶 LightweightZero dependencies, small bundle size
🔧 esbuild friendlyNo emitDecoratorMetadata required
📦 Feature-richClass, value, factory, async injection and more
⚛️ React readyBuilt-in hooks for React integration
Well tested100% code coverage

Quick Start

npm install @wendellhu/redi
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.

Features

Who’s Using redi?

License

MIT. Copyright 2021-present Wenzhao Hu.

Last updated on