{"record":{"id":"f338b5df99b84929","repo":"sveltejs/svelte","slug":"lifecycle-legacy-only","errorCode":"lifecycle_legacy_only","errorMessage":"lifecycle_legacy_only\n`${name}(...)` cannot be used in runes mode\nhttps://svelte.dev/e/lifecycle_legacy_only","messagePattern":"lifecycle_legacy_only\n`(.+?)\\(\\.\\.\\.\\)` cannot be used in runes mode\nhttps://svelte\\.dev/e/lifecycle_legacy_only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/client/errors.js","lineNumber":377,"sourceCode":"\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invalid_snippet`);\n\t}\n}\n\n/**\n * `%name%(...)` cannot be used in runes mode\n * @param {string} name\n * @returns {never}\n */\nexport function lifecycle_legacy_only(name) {\n\tif (DEV) {\n\t\tconst error = new Error(`lifecycle_legacy_only\\n\\`${name}(...)\\` cannot be used in runes mode\\nhttps://svelte.dev/e/lifecycle_legacy_only`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/lifecycle_legacy_only`);\n\t}\n}\n\n/**\n * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value\n * @param {string} key\n * @returns {never}\n */\nexport function props_invalid_value(key) {\n\tif (DEV) {\n\t\tconst error = new Error(`props_invalid_value\\nCannot do \\`bind:${key}={undefined}\\` when \\`${key}\\` has a fallback value\\nhttps://svelte.dev/e/props_invalid_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/props_invalid_value`);\n\t}","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/client/errors.js#L359-L395","documentation":"Thrown at index-client.js:206 and :229 inside beforeUpdate()/afterUpdate() when component_context.l is null, i.e. the component is in runes mode. These legacy lifecycle hooks rely on the pre-runes reactivity model and have no equivalent semantics under runes; Svelte 5 runes components must use $effect / $effect.pre instead.","triggerScenarios":"Importing and calling beforeUpdate(fn) or afterUpdate(fn) in a component that opts into runes mode (either explicitly via runes: true or implicitly because it uses runes like $state/$props). The guard checks component_context.l === null.","commonSituations":"Migrating a Svelte 4 component to Svelte 5 runes while leaving beforeUpdate/afterUpdate calls in place; copying legacy code into a runes component; library code that calls these hooks being used from a runes-mode app.","solutions":["Replace beforeUpdate(fn) with $effect.pre(fn).","Replace afterUpdate(fn) with $effect(fn).","Remove the legacy import (beforeUpdate/afterUpdate) once migrated."],"exampleFix":"// before\nimport { beforeUpdate, afterUpdate } from 'svelte';\nbeforeUpdate(() => { /* ... */ });\nafterUpdate(() => { /* ... */ });\n\n// after\n$effect.pre(() => { /* runs before DOM update */ });\n$effect(() => { /* runs after DOM update */ });","handlingStrategy":"validation","validationCode":"// Do not call beforeUpdate/afterUpdate in runes-mode components.\n// Detect runes mode: if your component uses $state/$props/$effect, it is in runes mode.\n// Replace beforeUpdate -> $effect.pre, afterUpdate -> $effect.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["During Svelte 4 -> 5 migration, replace beforeUpdate/afterUpdate with $effect.pre/$effect.","Remove legacy lifecycle imports once a component uses runes.","Audit library dependencies that call these hooks before using them from runes components."],"tags":["svelte","runes","lifecycle","migration","deprecation"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}