onMount: Running After Render
Execute code after the component has been added to the DOM.
onMount Purpose
onMount runs after the component is added to the DOM. Ideal for kicking off async work or accessing refs.
Import It
Import from svelte at the top of your script.
<script>
import { onMount } from "svelte";
</script>All lessons in this course
- onMount: Running After Render
- onDestroy: Cleanup
- beforeUpdate and afterUpdate
- tick(): Waiting for DOM Updates