Lifecycle Events — Fundamentals · NestJS

Open a connection in onModuleInit and seed data in onApplicationBootstrap, and see from the recorded order why the two hooks exist.

What you will learn

Read the theory for Lifecycle Events

All Fundamentals lessons

All NestJS courses

loading types…

What you'll learn

  • Implement OnModuleInit and OnApplicationBootstrap and place each hook in the boot sequence
  • Explain why hooks of one module run together, and why work that needs another provider ready belongs in onApplicationBootstrap
  • Describe the shutdown hooks, what enables them, and why a browser run never reaches them