{"record":{"id":"03f5e00284bf0b21","repo":"sveltejs/svelte","slug":"store-invalid-shape","errorCode":"store_invalid_shape","errorMessage":"store_invalid_shape\n`${name}` is not a store with a `subscribe` method\nhttps://svelte.dev/e/store_invalid_shape","messagePattern":"store_invalid_shape\n`(.+?)` is not a store with a `subscribe` method\nhttps://svelte\\.dev/e/store_invalid_shape","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/shared/errors.js","lineNumber":133,"sourceCode":"\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/snippet_without_render_tag`);\n\t}\n}\n\n/**\n * `%name%` is not a store with a `subscribe` method\n * @param {string} name\n * @returns {never}\n */\nexport function store_invalid_shape(name) {\n\tif (DEV) {\n\t\tconst error = new Error(`store_invalid_shape\\n\\`${name}\\` is not a store with a \\`subscribe\\` method\\nhttps://svelte.dev/e/store_invalid_shape`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/store_invalid_shape`);\n\t}\n}\n\n/**\n * The `this` prop on `<svelte:element>` must be a string, if defined\n * @returns {never}\n */\nexport function svelte_element_invalid_this_value() {\n\tif (DEV) {\n\t\tconst 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`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/svelte_element_invalid_this_value`);\n\t}\n}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/shared/errors.js#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nlet count = 0; // plain value\n$: doubled = $count * 2; // $count expects a store -> throws\n// after\nimport { writable } from 'svelte/store';\nconst count = writable(0);\n$: doubled = $count * 2;","handlingStrategy":"type-guard","validationCode":"function isStore(v) {\n\treturn v != null && typeof v.subscribe === 'function';\n}\nif (!isStore(maybeStore)) throw new Error('Expected a store with a subscribe method');","typeGuard":"function isStore(v) {\n\treturn v != null && typeof v.subscribe === 'function';\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["store","subscribe","svelte4","store-contract"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}