diff --git a/docs/guide/integration-with-svelte.md b/docs/guide/integration-with-svelte.md index ac6e39f53..3251034d4 100644 --- a/docs/guide/integration-with-svelte.md +++ b/docs/guide/integration-with-svelte.md @@ -4,18 +4,20 @@ The HyperFormula API is identical in a Svelte app and in plain JavaScript. What Install with `npm install hyperformula`. For other options, see the [client-side installation](client-side-installation.md) section. +The snippets below target **Svelte 5** (runes mode) — the current stable release. They assume a project created from the official `sv` / SvelteKit templates, which enable runes by default. + ::: warning SvelteKit SSR -The primary snippet below assumes a browser environment. If you use SvelteKit with default SSR, skip to [Server-side rendering](#server-side-rendering-sveltekit) — `HyperFormula.buildFromArray` at ` - - + + {#if result !== null}
Result: {result}
{/if} @@ -52,7 +53,7 @@ Declare the engine at the top of ` - - + + {#if result !== null}Result: {result}
{/if} ``` +Two details that matter for correctness: + +- **`$state` around `hf`** — the engine is assigned asynchronously inside `onMount`, so the variable needs to be reactive for `disabled={!hf}` to flip once the engine is ready. Svelte 5 does not deep-proxy class instances stored in `$state`, so the HyperFormula instance remains untouched; only the reassignment is tracked. +- **Dynamic `await import('hyperformula')` + type-only `import type`** — the runtime import keeps the module out of the server bundle, while `import type` is erased at compile time, so it adds nothing to the server payload while still giving you full type checking. ## Next steps