Schedules a callback to run immediately before the component is updated after any state change. The first time the callback runs will be before the initialDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sveltejs/svelte/llms.txt
Use this file to discover all available pages before exploring further.
onMount.
Signature
A function to run before the component updates.
Usage
Migration to runes
In runes mode, use$effect.pre instead:
Before (legacy mode)
After (runes mode)
Key differences
beforeUpdateonly works in legacy mode (non-runes components)$effect.preis the runes-mode equivalent$effect.preruns before DOM updates, similar tobeforeUpdate- The first run of
beforeUpdatehappens beforeonMount
Notes
- Only works in legacy mode
- Runs before every component update
- First run is before the initial
onMount - Does not run during server-side rendering