Next-generation dependency injection for TypeScript
Compiler-checked dependency graphs. Fast resolution. A runtime under 3 KiB. Your business logic stays ordinary TypeScript
pnpm add @inferdi/inferdi
A cached resolve starts with one Map.get(). The default contract keeps runtime checks on cold resolution.
Methodology and full resultsMedians from the recorded eight-round production benchmark. Container overhead, not application throughput. .
Each registration returns a new container type that records its key, value, lifetime, async edge, and scope requirements.
import { Container } from '@inferdi/inferdi'
class Logger {
info(message: string) {}
}
class Database {
findUser(id: string) {
return { id }
}
}
class UserRepo {
constructor(readonly logger: Logger, readonly database: Database) {}
}
const container = new Container()
.registerClass('logger', Logger, [])
.registerClass('database', Database, [])
.registerClass('users', UserRepo, ['logger', 'database'])
const users = container.get('users')
React 19Typed context, Suspense hooks, and managed scopes.
Fastify 5One typed scope per request with lifecycle cleanup.
Hono 4Typed context variables for Workers, Bun, and Node.
Koa 3Request scopes that follow the middleware lifecycle.
Express 5Typed request scopes for middleware and routes.
Elysia 1Route-aware types carried into request services.Keep the graph in one place, where its choices are easy to read and change.