Skip to content

Option to make prerender opt-out rather than opt-in #3792

@madeleineostoja

Description

@madeleineostoja

Describe the problem

For large headless / static sites with a bit of api glue code, marking every single route with export const prerender = true is both unergonomic and unintuitive, considering other major serverless frameworks (eg: Next) automatically prerender all routes when possible.

A common pattern is to have all routes prerendered, and then an api/ route or similar for endpoints that would get translated to serverless functions you can request to.

Describe the proposed solution

There should be an option to make prerendering opt-out rather than opt-in for serverless adapters. Ideally an adapter like Vercel should attempt to prerender all routes by default, while keeping endpoints as serverless functions. That would be a fairly major breaking change, so making this a configuration option (false by default) would be a non-breaking and huge erganomic upgrade. Though I still think the default behaviour is odd, given kit's emphasis on performance and DX.

Alternatives considered

  1. Mark every route with export const prerender = true, unintuitive and prone to user-error
  2. Use adapter-static and manually deploy serverless functions for api routes / endpoints to provider of choice, largely negating the whole benefit of Sveltekit's deep serverless integration

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions