sveltejs/svelte · error · Error
store_invalid_shape
store_invalid_shape
Error message
store_invalid_shape
`${name}` is not a store with a `subscribe` method
https://svelte.dev/e/store_invalid_shape What it means
Svelte's store contract requires an object with a `subscribe` method (optionally `set`/`update`). When you auto-subscribe with `$store` or pass a value to a store-expecting API, Svelte checks for `subscribe`. If absent, it throws naming the invalid store (`%name%`). Applies to Svelte 4 `$`-prefixed stores and Svelte 5 store interop.
Source
Thrown at packages/svelte/src/internal/shared/errors.js:133
} else {
throw new Error(`https://svelte.dev/e/snippet_without_render_tag`);
}
}
/**
* `%name%` is not a store with a `subscribe` method
* @param {string} name
* @returns {never}
*/
export function store_invalid_shape(name) {
if (DEV) {
const error = new Error(`store_invalid_shape\n\`${name}\` is not a store with a \`subscribe\` method\nhttps://svelte.dev/e/store_invalid_shape`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/store_invalid_shape`);
}
}
/**
* The `this` prop on `<svelte:element>` must be a string, if defined
* @returns {never}
*/
export function svelte_element_invalid_this_value() {
if (DEV) {
const error = new Error(`svelte_element_invalid_this_value\nThe \`this\` prop on \`<svelte:element>\` must be a string, if defined\nhttps://svelte.dev/e/svelte_element_invalid_this_value`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/svelte_element_invalid_this_value`);
}
}View on GitHub (pinned to 20b341f100)
Solutions
- Ensure the variable is a store: wrap with `writable(...)`, `readable(...)`, or `derived(...)`.
- If you meant a plain value, remove the `$` prefix.
- Verify the store object actually has a `subscribe` function (not overwritten or undefined).
Example fix
// before
let count = 0; // plain value
$: doubled = $count * 2; // $count expects a store -> throws
// after
import { writable } from 'svelte/store';
const count = writable(0);
$: doubled = $count * 2; Defensive patterns
Strategy: type-guard
Validate before calling
function isStore(v) {
return v != null && typeof v.subscribe === 'function';
}
if (!isStore(maybeStore)) throw new Error('Expected a store with a subscribe method'); Type guard
function isStore(v) {
return v != null && typeof v.subscribe === 'function';
} Prevention
- Wrap reactive values in `writable`/`readable` before `$`-subscribing.
- Validate store shape before passing to `derived`.
- Do not `$`-subscribe plain variables.
- Check for `undefined` stores from failed imports.
When it happens
Trigger: Using `$value` where `value` is not a store (plain object, array, primitive); passing a non-store to `derived()`; a store whose `subscribe` was deleted/renamed; auto-subscribing an `undefined` variable.
Common situations: Forgetting to wrap a value in `writable()`/`readable()`; passing a plain object where a store is expected; SSR/import issues yielding `undefined`; refactoring that drops the store wrapper.
Related errors
- Your application, or one of its dependencies, imported from
- derived() expects stores as input, got a falsy value
AI-assisted analysis of sveltejs/svelte@20b341f100 (2026-08-12).
Data as JSON: /api/errors/03f5e00284bf0b21.
Report an issue: GitHub.