Install the package
Resilience is available on npm and can be installed using any package manager:Requirements
- Node.js: 16.x or higher
- TypeScript: 5.x or higher (optional, but recommended)
Resilience is an ESM-only package. Make sure your project is configured to use ES modules.
TypeScript setup
Resilience is written in TypeScript and includes type definitions out of the box. No additional setup is required. The library exports all type definitions you need:Type definitions included
Resilience provides full TypeScript support with these key types:ResilienceConfig- Configuration options forwithResilienceBackoffStrategy- Fixed or exponential backoff configurationCircuitBreakerConfig- Circuit breaker threshold and timeout settingsResilienceHooks- Lifecycle hooks for observabilityCircuitState- Circuit breaker state (CLOSED,OPEN,HALF_OPEN)
ESM configuration
Since Resilience is an ESM package, ensure yourpackage.json includes:
tsconfig.json should have:
Verify installation
Create a simple test file to verify everything is working:Bundle size
Resilience is lightweight and has zero dependencies:- Uncompressed: ~8 KB
- Minified: ~3 KB
- Gzipped: ~1.5 KB
- Browser applications
- Serverless functions (AWS Lambda, Cloudflare Workers, etc.)
- Edge computing environments
- Microservices where bundle size matters
Environment support
Resilience works in any JavaScript environment that supports:- Promises and async/await
setTimeoutandDate.now()AbortControllerandAbortSignal(optional, for timeout cancellation)
Next steps
Quickstart
Get started with your first resilient function
Core concepts
Learn about retries, backoff, and circuit breakers

