Inversify and Awilix Alternative for TypeScript Dependency Injection
ts-ioc-container is a thin, explicit TypeScript dependency injection container
for teams that want richer application features without a heavy container model.
It keeps containers local to your app boundary, avoids global container objects,
and exposes a clean API for scopes, tokens, providers, decorators, hooks, and
lazy dependencies.
Why Look Beyond Heavy DI?
Inversify and Awilix are useful when a project wants their particular container
style and conventions. ts-ioc-container is designed for teams that want the DI
surface to stay smaller: create a container, create explicit scopes, register
dependencies, resolve them, and dispose them without making a global container
the center of the application.
Cleaner API
The core API is intentionally direct. Most workflows are expressed through a few
concepts: Container, Registration, Provider, Injector, and typed tokens.
Advanced behavior lives in composable provider pipes, registration pipes, and
hooks instead of requiring every app to adopt a large object graph convention.
const app = new Container({ tags: ['application'] })
.addRegistration(R.fromClass(Logger).pipe(singleton()))
.addRegistration(R.fromClass(UserService));
const request = app.createScope({ tags: ['request'] });
const service = request.resolve<UserService>('UserService');const app = new Container({ tags: ['application'] })
.addRegistration(R.fromClass(Logger).pipe(singleton()))
.addRegistration(R.fromClass(UserService));
const request = app.createScope({ tags: ['request'] });
const service = request.resolve<UserService>('UserService');No Global Objects
The container is an object you own. Keep it at the composition root, create child scopes for requests or UI lifecycles, and pass the current scope through framework boundaries such as Express middleware, Fastify decorators, React Context, or SolidJS Context.
This makes dependency flow explicit and testable. Tests can build isolated containers without resetting shared module-level state.
Feature Comparison
| Need | ts-ioc-container fit |
|---|---|
| Thin runtime model | Small set of core abstractions instead of a broad container object surface |
| Clean API | Register, scope, resolve, decorate, hook, and dispose through direct APIs |
| No global container object | Containers and child scopes are passed explicitly through app boundaries |
| Richer than basic DI | Scoped lifecycles, tokens, aliases, lazy dependencies, hooks, and provider pipes |
| Framework-friendly scopes | Request, transaction, page, widget, and application scopes through tags |
| Customization | Custom providers, custom injectors, hooks, pipes, aliases, and metadata utilities |
| Testability | Build isolated containers per test without shared global state |
When Inversify or Awilix Is Enough
Choose Inversify or Awilix when your team already wants their container style, module conventions, or registration model and the additional surface area is not a concern.
When ts-ioc-container Fits Better
Choose ts-ioc-container when you want a cleaner API than heavy DI containers,
more application lifecycle features than minimal DI, explicit scope passing, and
no global container object.
Continue with the Product Capabilities map, the tsyringe alternative comparison, or Dependency and Scope.