Skip to content
Latchkey

SvelteKit "Cannot prerender pages with actions" in CI

Prerendering produces static HTML at build time, but form actions run on the server per request. A route cannot be both static and have server actions, so SvelteKit fails the build when both are present.

What this error means

svelte-kit build fails with "Cannot prerender pages with actions" naming a +page.server.js route that exports actions while prerendering is enabled for it.

sveltekit
> Cannot prerender pages with actions
    at /src/routes/contact/+page.server.js

Common causes

A prerendered route exports form actions

The route sets prerender = true (or inherits it) yet defines actions, which require a live server, so the two conflict.

A global prerender default catches an interactive page

A root layout sets prerender = true for the whole app, sweeping in a page that genuinely needs server actions.

How to fix it

Disable prerendering for the action route

Mark the interactive route as not prerendered so its actions run on the server.

src/routes/contact/+page.server.js
// src/routes/contact/+page.server.js
export const prerender = false;

Scope the prerender default more narrowly

If a layout enables prerendering globally, override it on routes that need actions instead of disabling it everywhere.

src/routes/contact/+page.server.js
// keep static pages prerendered, opt this one out
export const prerender = false;

How to prevent it

  • Set prerender = false on any route with form actions.
  • Apply global prerender defaults carefully in layouts.
  • Keep static content and interactive forms in separate routes where possible.

Frequently asked questions

What causes ""Cannot prerender pages with actions""?
The route sets prerender = true (or inherits it) yet defines actions, which require a live server, so the two conflict.
How do I fix "Cannot prerender pages with actions"?
Mark the interactive route as not prerendered so its actions run on the server.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card