Formingcli_toolpublished fresh until

SvelteKit / Svelte 5: migrate stores to runes incrementally?

Summary As of October 2026, keep working stream stores, move ordinary shared state into .svelte.ts factories, and replace computed store values with $derived while checking SSR isolation on Svelte 5.57.3

Not for Svelte 5 $state losing reactivity across function arguments, see svelte-5-state-stops-updating-when-passed-to-a-function-getter-or-object

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
Acli_tool · v1.1.1Svelte sv CLI
How you use itcli_tool
What it can doinstalls software · network
What's inside
Acli_tool · v1.1.1Svelte sv CLI
How you use it
cli_tool
What it can do
installs software · network
What's inside

What this thread does

Migrate ordinary shared state one dependency chain at a time into rune-aware factories, while keeping stores that provide useful subscription or stream semantics.

Do first: check package.json for the installed Svelte major

1. Record installed dependencies and passing checks before refactoring. This recipe starts with store-based code on Svelte 5, not a whole Svelte 4 upgrade. As of November 2026, the latest stable reference is Svelte 5.59.1, checked 2026-11-24. 2. Classify each store: component-local value, shared UI model, request/user state, or external stream/custom subscription. Keep stores where their explicit subscription lifecycle remains useful; the stores guide still supports them and recommends runes for ordinary extracted/shared state. 3. Move one model to a .svelte.ts factory. Return an object whose property can be read and mutated; avoid exporting a reassigned primitive. Example authored replacement for a counter store:

// counter.svelte.ts
export function createCounter(initial = 0) {
  const state = $state({ count: initial });
  return {
    state,
    increment() { state.count += 1; }
  };
}
<script lang="ts">
  import { createCounter } from './counter.svelte';
  const counter = createCounter();
  let doubled = $derived(counter.state.count * 2);
</script>
<button onclick={() => counter.increment()}>
  {counter.state.count} / {doubled}
</button>

Read counter.state.count at the use site. Destructuring the primitive count into another variable takes a value rather than creating a reactive link. The $state documentation explains proxy state and cross-module restrictions; $derived tracks reactive computations. 4. If siblings must share the model, create it in their common owner and pass it down, or put it in context. For SvelteKit SSR, create user/request state per request/component tree. Do not replace a module-global store holding user data with module-global rune state: both can leak data between requests. Follow SvelteKit state management. 5. Update consumers and derived values together. Keep $store access for stores inside components. At a non-component boundary that needs rune access to a retained store, use the documented fromStore(store).current; use toStore when a store consumer must observe rune state. See svelte/store interoperability. 6. Verify initial render, mutation, two consumers sharing one instance, destruction/subscription cleanup, and server rendering with two separate user contexts. Run the project's existing type, component and build checks before moving to the next model.

What changes, and what does not

Existing operationMigration action
writable used as a shared mutable UI modelConsider an object created by $state inside a .svelte.ts factory. Replace .set/.update calls at each consumer deliberately.
derived value dependent on migrated stateUse $derived in a rune-aware scope, or expose a getter for a computation. Do not leave a store dependency graph silently disconnected.
Side-effecting subscriptionPreserve its cleanup; choose an effect only if its lifecycle and client-only execution fit.
External observable/custom store with useful lifecycleKeep its store contract, bridging only the boundary that needs it.

$effect runs in the browser, not during SSR. Prefer $derived for values the page needs on first server render. An effect that writes a second state variable to mirror the first adds avoidable synchronization.

Broader migration boundary

The Svelte 5 migration guide allows legacy and rune components together. If you also convert component syntax, review props/bindings, event handlers, snippets, component construction and lifecycle differences separately. Its npx sv migrate svelte-5 automates some syntax changes, not every semantic decision. A store refactor is not evidence that all major-version breaking changes have been handled.

Options, cost and limits — checked 2026-10-28

OptionWins whenLoses whenPick this if
Retain storesSubscription APIs, explicit cleanup or existing integrations are usefulSimple shared state requires repetitive wrapper codeExisting behaviour is correct and the subscription contract earns its place.
Rune factoryYou want ordinary reactive state and reusable logic owned by a component treeConsumers still require store APIs and the ownership boundary is unclearYou can migrate one complete dependency chain and keep request state isolated.

Both APIs are part of Svelte; this is no new hosted subscription or service-quota decision. The real cost is refactoring, testing consumers and maintaining interoperability, not a promised runtime speedup.

Public evidence

newsve, Svelte discussion 14835, 2024-12-26: “migrate bottom-up and not top-down”. The author reports rune/store dependency surprises and recommends changing dependent layers together. This is useful historical migration experience, not an authoritative statement that every example in the discussion remains current; use the current interoperability docs above.

Recommendation by constraint

Solo developer: keep working stores and migrate one model only when it simplifies code. Small team: consider rune factories for new ordinary state when ownership is clear and consumers do not require store APIs, retaining store boundaries until their consumers are ready. Enterprise SvelteKit app: prioritize SSR ownership and regression checks; migrate by model/component boundary rather than forcing a global rewrite.

Prompt for the agent

Inventory stores and their consumers in this Svelte 5 app. Pick one ordinary UI model, preserve subscription boundaries and convert its complete dependency chain to a per-owner rune factory. Show where SSR instances are created and test separate user contexts. Keep unrelated component and framework upgrades separate.

Mistakes and Limits

Do not destructure reactive primitives expecting live references, mechanically replace every derived import, or use module-global user state. No app was compiled, benchmarked or migrated here. The community evidence is one older discussion. This does not establish a previous supported Svelte 4 baseline or audit all intervening release notes; apps still on Svelte 4 need the complete official upgrade review first.

Started from a post by @Svelte contributors, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# SvelteKit / Svelte 5: migrate stores to runes incrementally?
Summary: As of October 2026, keep working stream stores, move ordinary shared state into .svelte.ts factories, and replace computed store values with $derived while checking SSR isolation on Svelte 5.57.3

## Options
- A · Svelte sv CLI · early, no verdict yet · installs software · network
Copy for agent
get the whatworks thread svelte-5-stores-to-runes-incremental-migration and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread svelte-5-stores-to-runes-incremental-migration

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Svelte sv CLI

Creates and migrates Svelte projects. Pinned sv@1.1.1 from npm, run from a locked install: WhatWorks checks only its --version and --help.

Format
cli_tool
Source
—
Pinned
v1.1.1 · npm:sv@1.1.1
Content hash
sha256:2f0c6e1ba
Audit
scan warned
Can do
installs software · network
Check
node_modules/.bin/sv --version; node_modules/.bin/sv --help
Author
editor
Kudos
0

This package has no public source link yet.

Ask your agent
show me the whatworks package sv-cli-tool before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp