When used inside aDocumentation 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.
$derived or $effect, any state read inside fn will not be treated as a dependency.
Parameters
A function to execute without tracking dependencies. Any reactive state accessed within this function will not cause the containing effect or derived to re-run
Returns
The return value of the
fn functionExamples
Saving data with timestamp
Reading state without creating dependency
Conditional dependency
Preventing infinite loops
Accessing context without dependency
Use cases
- Logging: Read reactive state for logging purposes without creating unnecessary dependencies
- Timestamps: Add metadata (like timestamps) that shouldn’t trigger re-runs
- Conditional dependencies: Only track certain values when specific conditions are met
- Breaking circular dependencies: Update state within an effect that reads related state
- Performance optimization: Prevent unnecessary reactivity for values that don’t need to trigger updates
Notes
untrack()only affects dependency tracking, not the execution of the function- The function passed to
untrack()is executed immediately and synchronously - This is particularly useful in
$effectand$derivedcontexts where automatic dependency tracking occurs - State reads inside
untrack()still return the current reactive value, they just don’t create dependencies