Introduction
The onMount function runs code right after a Svelte component appears on the screen. It helps you start tasks like loading data or setting up timers.
You want to fetch data from a server when a page or component loads.
You need to start a timer or animation when a component shows up.
You want to focus an input box automatically after the component appears.
You need to set up event listeners that depend on the component being visible.