Skip to content
CIVersionSizeTypeScriptDependencies
Wireit logo

Wireit

⚡ Quick Reference

Package: @vielzeug/wireit  ·  Category: Di

Key exports: createContainer, createToken

When to use: Type-safe DI container with singleton/transient lifetimes, child scopes, async providers, and circular dependency detection.

Related: Logit · Eventit · Permit

@vielzeug/wireit is a compact dependency injection container built around typed symbol tokens, factory registration, and explicit container scopes.

Installation

sh
pnpm add @vielzeug/wireit
sh
npm install @vielzeug/wireit
sh
yarn add @vielzeug/wireit

Quick Start

ts
import { createContainer, createToken } from '@vielzeug/wireit';

const Logger = createToken<{ log(message: string): void }>('Logger');
const Service = createToken<{ run(): Promise<void> }>('Service');

const container = createContainer();

container.value(Logger, console);
container.factory(Service, (logger) => ({ run: async () => logger.log('Running service') }), {
  deps: [Logger],
});

const service = await container.resolve(Service);
await service.run();

await container.dispose();

Why Wireit?

Manual dependency wiring often spreads across modules, making lifetimes and teardown behavior difficult to reason about in larger systems.

FeatureWireittsyringeInversifyJS
Bundle size1.2 KB~6 kB~45 kB
Typed token ergonomicsPartialPartial
Async-first resolutionPartialPartial
Child container scopes
Explicit disposal lifecyclePartial
Decorator-free usage❌ (decorator-oriented)⚠️ (commonly decorator-oriented)
Zero dependencies

Use Wireit when you need a compact typed container with explicit scopes and lifecycle control.

Consider decorator-heavy DI frameworks when your project is already standardized around metadata/decorator injection patterns.

Features

  • Small core API
  • Typed dependency contracts
  • Async-first resolution
  • Child containers for scope boundaries
  • Explicit disposal

Compatibility

EnvironmentSupport
Browser
Node.js
SSR
Deno

Documentation

See Also

  • Workit for dependency-managed worker orchestration.
  • Eventit for pub/sub coordination in container-managed modules.
  • Permit for injecting authorization services.