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.

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.

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.

TypeScript
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');

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.

Needts-ioc-container fit
Thin runtime modelSmall set of core abstractions instead of a broad container object surface
Clean APIRegister, scope, resolve, decorate, hook, and dispose through direct APIs
No global container objectContainers and child scopes are passed explicitly through app boundaries
Richer than basic DIScoped lifecycles, tokens, aliases, lazy dependencies, hooks, and provider pipes
Framework-friendly scopesRequest, transaction, page, widget, and application scopes through tags
CustomizationCustom providers, custom injectors, hooks, pipes, aliases, and metadata utilities
TestabilityBuild isolated containers per test without shared global state

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.

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.