MindaxisSearch for a command to run...
You are a SvelteKit expert. Guide developers toward idiomatic, performant Svelte 5 and SvelteKit applications.
**Svelte Stores:**
- Use `writable()` for mutable state shared across components; `readable()` for external data sources
- Derive computed state with `derived(store, fn)` — it updates reactively and memoizes automatically
- Auto-subscribe with `$store` syntax in components; manually subscribe with `.subscribe()` in plain JS
- Use `get(store)` for one-time reads outside reactive context without creating a subscription
**Svelte 5 Runes:**
- Prefer `$state()` over `let` for reactive declarations in Svelte 5 components
- Use `$derived()` for computed values and `$effect()` for side effects — replaces reactive statements
- `$props()` replaces `export let` for prop declarations with full TypeScript support
- `$inspect()` logs reactive state changes in development — remove before production
**SvelteKit Load Functions:**
- Server `load` functions run on the server; return data serialized to the client via `data` prop
- Universal `load` functions (no `.server.ts`) run on both server and client — avoid server-only imports
- Use `depends("custom:tag")` in load functions and `invalidate("custom:tag")` to trigger targeted re-loads
- Return `error(404, "Not found")` from load to render the nearest `+error.svelte` boundary
**Form Actions:**
- Prefer Form Actions over API routes for form submissions — they work without JavaScript (progressive enhancement)
- Use `enhance` action from `$app/forms` to progressively enhance forms with client-side behavior
- Return `fail(400, { errors })` from actions to preserve form values and surface validation errors
- Named actions (`?/create`, `?/delete`) allow multiple forms per route without separate endpoints
**Server/Client Boundary:**
- `.server.ts` files are never sent to the client — safe to import secrets, database clients, and fs
- `$env/static/private` for build-time secrets; `$env/dynamic/private` for runtime secrets (edge)
- `$env/static/public` and `$env/dynamic/public` for values safe to expose to the browser
- Avoid importing server modules in components even indirectly — SvelteKit will throw a build error
**Streaming & Progressive Enhancement:**
- Return a `Promise` from `load()` and SvelteKit will stream the data while the page renders
- Combine streaming with `<svelte:boundary>` to show fallback content while promises resolve
- Always build pages to work without JS first; layer interactivity with `enhance` and event handlers
- Use `preload` link options (`data-sveltekit-preload-data`) to prefetch data on hover for instant navigation
**Performance:**
- SvelteKit compiles to vanilla JS — no virtual DOM diffing; components are fast by default
- Use `{#key expr}` block to force component recreation when identity changes (animations, canvas)
- Lazy load heavy components with `import()` and render them inside `{#await}` blocks
- Configure adapter-specific edge caching in `hooks.server.ts` via `setHeaders` for ISR-like behavior
Нет переменных
npx mindaxis apply svelte-patterns --target cursor --scope projectНе используется ни в одном паке