{"record":{"id":"9d5ce1d3220a2581","repo":"sveltejs/kit","slug":"the-form-action-returned-an-error-but-error-svel","errorCode":null,"errorMessage":"The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance","messagePattern":"The form action returned an error, but \\+error\\.svelte wasn't rendered because SSR is off\\. To get the error page with CSR, enhance your form with `use:enhance`\\. See https://svelte\\.dev/docs/kit/form-actions#progressive-enhancement-use-enhance","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/server/page/index.js","lineNumber":122,"sourceCode":"\n\t\t/** @type {import('./types.js').Fetched[]} */\n\t\tconst fetched = [];\n\n\t\tconst ssr = nodes.ssr();\n\t\tconst csr = nodes.csr();\n\n\t\t// renders an empty 'shell' page if SSR is turned off and if there is\n\t\t// no server data to prerender. As a result, the load functions and rendering\n\t\t// only occur client-side.\n\t\tif (\n\t\t\tssr === false &&\n\t\t\t!((state.prerendering || state.prerender_default === true) && should_prerender_data)\n\t\t) {\n\t\t\t// if the user makes a request through a non-enhanced form, the returned value is lost\n\t\t\t// because there is no SSR or client-side handling of the response\n\t\t\tif (DEV && action_result && !event.request.headers.has('x-sveltekit-action')) {\n\t\t\t\tif (action_result.type === 'error') {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance\"\n\t\t\t\t\t);\n\t\t\t\t} else if (action_result.data) {\n\t\t\t\t\t/// case: lost data\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"The form action returned a value, but it isn't available in `page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn await render_response({\n\t\t\t\t// provide nodes without running load functions so that the styles and\n\t\t\t\t// fonts are linked in the head before CSR takes over\n\t\t\t\tbranch: compact(nodes.data).map((node) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\tserver_data: null","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/index.js#L104-L140","documentation":"When a form posts to an action without `use:enhance` and SSR is off, SvelteKit has no way to render the returned error page or deliver the action result to `page.form` — the value is silently lost. In dev, this warning explains why the result vanished and points to progressive enhancement.","triggerScenarios":"A plain `<form method=\"POST\" action=\"?/action\">` (no `use:enhance`) submits, the action returns `fail(...)`/`error(...)` (type 'error'), and the page is rendered with `ssr = false` (or prerendering config skips SSR), detected via absence of the `x-sveltekit-action` header in dev.","commonSituations":"Disabling SSR per-page or globally while keeping plain HTML forms; forgetting `use:enhance` when moving a page to CSR-only; prerender-enabled apps receiving action POSTs.","solutions":["Add `use:enhance` from `$app/forms` to the form element","Re-enable SSR for pages whose actions return errors/data","Handle failures client-side yourself with a custom submit handler"],"exampleFix":"<!-- before -->\n<form method=\"POST\" action=\"?/create\">\n<!-- after -->\n<script>\nimport { enhance } from '$app/forms';\n</script>\n<form method=\"POST\" action=\"?/create\" use:enhance>","handlingStrategy":"fallback","validationCode":"// detect the risky combination before submit\nif (!formEl.dataset.enhanced && !document.documentElement.dataset.ssr) {\n  console.warn('Action results will be lost: add use:enhance or enable SSR');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add use:enhance to forms posting to actions","Avoid ssr=false on pages with form actions","Test action error paths with SSR disabled in dev to catch this early"],"tags":["forms","ssr","csr","use-enhance","dev-warning"],"backgroundTag":"form-result-lost-ssr-off","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}