{"record":{"id":"42e7e80e633e56ac","repo":"sveltejs/kit","slug":"cannot-prerender-pages-with-actions","errorCode":null,"errorMessage":"Cannot prerender pages with actions","messagePattern":"Cannot prerender pages with actions","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/server/page/index.js","lineNumber":89,"sourceCode":"\t\t\tif (action_result?.type === 'redirect') {\n\t\t\t\treturn redirect_response(action_result.status, action_result.location);\n\t\t\t}\n\t\t\tif (action_result?.type === 'error') {\n\t\t\t\tstatus = get_status(action_result.error);\n\t\t\t}\n\t\t\tif (action_result?.type === 'failure') {\n\t\t\t\tstatus = action_result.status;\n\t\t\t}\n\t\t}\n\n\t\t// it's crucial that we do this before returning the non-SSR response, otherwise\n\t\t// SvelteKit will erroneously believe that the path has been prerendered,\n\t\t// causing functions to be omitted from the manifest generated later\n\t\tconst should_prerender = nodes.prerender();\n\t\tif (should_prerender) {\n\t\t\tconst mod = leaf_node.server;\n\t\t\tif (mod?.actions) {\n\t\t\t\tthrow new Error('Cannot prerender pages with actions');\n\t\t\t}\n\t\t} else if (state.prerendering) {\n\t\t\t// if the page isn't marked as prerenderable, then bail out at this point\n\t\t\treturn new Response(undefined, {\n\t\t\t\tstatus: 204\n\t\t\t});\n\t\t}\n\n\t\t// if we fetch any endpoints while loading data for this page, they should\n\t\t// inherit the prerender option of the page\n\t\tstate.prerender_default = should_prerender;\n\n\t\tconst should_prerender_data = nodes.should_prerender_data();\n\t\tconst data_pathname = add_data_suffix(event.url.pathname);\n\n\t\t/** @type {import('./types.js').Fetched[]} */\n\t\tconst fetched = [];\n","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/index.js#L71-L107","documentation":"Prerendering executes pages at build time with no ability to mutate server state, so a page whose `+page.server.js` exports `actions` cannot be prerendered. `render_page` throws when `export const prerender = true` coexists with server `actions`.","triggerScenarios":"Setting `export const prerender = true` in `+page.js`/`+layout.js` (or enabling prerender globally in svelte.config.js) on a route that also has `export const actions` in `+page.server.js`.","commonSituations":"Turning on `prerender = true` in the root layout and later adding a login/contact form to a page; copy-pasting a prerender config into a form page; `export const prerender = 'auto'` resolving to true for an action page.","solutions":["Remove `actions` from the page's `+page.server.js` (use a `+server.js` POST endpoint or client-side handling instead)","Set `export const prerender = false` for that page (e.g. via `+page.js`) to exclude it from prerendering","If prerendering globally, scope `prerender = true` to routes without actions"],"exampleFix":"// +page.js (before)\nexport const prerender = true;\n// after\nexport const prerender = false; // page has server actions","handlingStrategy":"validation","validationCode":"// +page.js\nexport const prerender = !import.meta.env.SSR ? true : typeof pageActions === 'undefined';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit pages with `export const prerender = true` for server actions","Prefer `prerender = 'auto'` sparingly and keep forms on non-prerendered routes","Separate state-changing flows into +server.js endpoints so pages can stay prerenderable"],"tags":["sveltekit","prerendering","form-actions","build-time"],"backgroundTag":"prerender-incompatible-feature","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}