# OnApplicationBootstrap

**Kind:** Interface

**Source:** [`packages/common/interfaces/hooks/on-application-bootstrap.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/common/interfaces/hooks/on-application-bootstrap.interface.ts#L9)

**Part of:** [Common](subsystem-packages-common)

Interface defining method called once the application has fully started and
is bootstrapped.

`OnApplicationBootstrap` defines the `onApplicationBootstrap()` lifecycle hook, which Nest calls once the application has completed module initialization and bootstrapping. Implement this interface in providers that need to perform final startup work, such as warming caches, validating external dependencies, or initializing background processes.

## Diagram

```mermaid
graph LR
  A[Nest application bootstrap] --> B[Initialize modules and providers]
  B --> C[Find providers implementing OnApplicationBootstrap]
  C --> D[Call onApplicationBootstrap()]
  D --> E[Run final startup tasks]
  E --> F[Application ready to serve requests]
```

## Usage

```ts
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';

@Injectable()
export class CacheWarmupService implements OnApplicationBootstrap {
  async onApplicationBootstrap(): Promise<void> {
    // Perform startup work after all modules are initialized.
    await this.warmCache();
  }

  private async warmCache(): Promise<void> {
    console.log('Warming application cache...');
  }
}
```

## AI Coding Instructions

- Implement `OnApplicationBootstrap` on injectable providers that require work after all application modules have initialized.
- Keep `onApplicationBootstrap()` focused on startup orchestration; move substantial logic into dedicated private methods or services.
- Return or await promises for asynchronous initialization so Nest can complete the lifecycle hook correctly.
- Avoid placing request-specific logic in this hook, since it runs once during application startup.
- Use this hook when initialization depends on providers from multiple modules being available.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `callModuleBootstrapHook` — `packages/core/hooks/on-app-bootstrap.hook.ts`:43
