Skip to main content
Glama

MCP Svelte Docs Server

# $state.snapshot Definition **Definition:** Static snapshot of reactive state **Syntax:** `$state.snapshot<T>(state: T): Snapshot<T>` **Parameters:** - `state` - The reactive state to snapshot **Returns:** Static snapshot that doesn't trigger reactivity **Variants:** - Part of `$state` rune family ## Examples ```js // Create reactive state let user = $state({ name: 'Alice', posts: ['Hello', 'World'] }); // Create static snapshot let userSnapshot = $state.snapshot(user); // Snapshot is static - won't trigger reactivity when accessed console.log(userSnapshot.name); // 'Alice' - no reactivity // Original state still reactive user.name = 'Bob'; // Triggers reactivity // Snapshot remains unchanged console.log(userSnapshot.name); // Still 'Alice' // Use in effects to avoid infinite loops $effect(() => { const snapshot = $state.snapshot(user); localStorage.setItem('user', JSON.stringify(snapshot)); }); ``` ## Related - `$state` - For reactive state that can be snapshotted - `$state.raw` - For non-deeply-reactive state - `$effect` - Often used with snapshots to avoid infinite loops

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/spences10/mcp-svelte-docs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server