Skip to main content

Migration Guide - v1 to v2

@brushy/di v2 splits the library into focused packages while keeping the umbrella install. Starting a new project? See Getting Started for install order by stack.

Package structure

Import changes

Subpath exports on the umbrella:

Typed tokens (new)

useInjectLazy (lazy proxy)

useInjectLazy returns a proxy that resolves the service on first property or method access:

Deprecated

  • useLazyInject → use useInjectLazy

Component injection (React)

Register UI on the container with useValue. Prefer createToken() (Symbol at runtime) over string tokens:
Resolve in components with useInjectComponent(SIDEBAR). Types infer from the registered component; explicit generics are optional. See Component Injection.

OpenTelemetry (optional)

Install @brushy/di-otel or use the umbrella /otel subpath. Requires @opentelemetry/api.

React Native

Install @brushy/di + react. Metro resolves react-native field automatically. No decorators required. Register a custom dev error renderer for useInjectComponent:
See Getting Started.

Backend

Use @brushy/di-core or @brushy/di with server utilities. Request scope cleanup remains manual or use middleware pattern (see server docs).