Run code at important moments in a component's life, from setup to cleanup.
Components go through different stages during their lifetime. Svelte provides lifecycle APIs that let you run logic when a component is mounted and perform cleanup when it is no longer needed.
Lifecycle behavior is useful for tasks such as starting subscriptions, interacting with browser APIs, setting up timers, and cleaning up resources. It is important to understand when lifecycle code runs so that browser-only work does not accidentally execute in the wrong environment.
What you'll walk away knowing