{"record":{"id":"562273316f0d4e6f","repo":"sveltejs/kit","slug":"the-form-action-returned-a-value-but-it-isn-t-ava","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/server/page/index.js","lineNumber":127,"sourceCode":"\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\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\tfetched,\n\t\t\t\tpage_config: {\n\t\t\t\t\tssr: false,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/index.js#L109-L145","documentation":"When SSR is disabled (`ssr = false` or `export const ssr = false`), the server renders no HTML, so a value returned by a form action cannot be placed into `page.form` in the initial response. SvelteKit warns that the action's return value is being lost and recommends using `use:enhance` so the result is delivered via the client-side fetch instead.","triggerScenarios":"A `<form method=\"POST\">` posts to an action on a page with SSR off, the action returns `{ success: true, ... }` (non-error data), and the form is NOT enhanced with `use:enhance`; render_page detects `action_result.data` but cannot serialize it into the CSR-only render.","commonSituations":"Progressive-enhancement pages exported with `export const ssr = false` where developers expect `page.form` to be populated after a plain (non-JS-enhanced) form submission.","solutions":["Enhance the form with `use:enhance` from `$app/forms` so the action result reaches the client.","Enable SSR for the page (`export const ssr = true` or remove the override) so `page.form` is hydrated server-side.","Redesign the action to redirect on success instead of returning data if you must keep SSR off and no enhance."],"exampleFix":"<!-- before -->\n<form method=\"POST\" action=\"?/create\">...</form>\n<!-- after -->\n<script>\n  import { enhance } from '$app/forms';\n</script>\n<form method=\"POST\" action=\"?/create\" use:enhance>...</form>","handlingStrategy":"fallback","validationCode":"// client-side check before relying on page.form\nif (!ssrEnabledForThisRoute && !formIsEnhanced) {\n  console.warn('action return value will be lost; use use:enhance or enable SSR');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always enhance forms with `use:enhance` when a page has `ssr = false`.","Avoid returning data from actions on CSR-only pages; prefer redirects.","Document per-route SSR settings so form handling matches the render mode."],"tags":["form-actions","ssr","sveltekit"],"backgroundTag":"ssr-disabled-form-data-lost","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}