Skip to content

Conversation

@jamesopstad
Copy link
Contributor

@jamesopstad jamesopstad commented Dec 18, 2025

Adds an experimental prerenderWorker option for defining a dedicated Worker for pre-rendering.

Example:

cloudflare({
  experimental: {
    prerenderWorker: {
      config(_, { entryWorkerConfig }) {
        return {
          ...entryWorkerConfig,
          name: "prerender",
          main: "./src/prerender.ts",
        };
      },
    },
  },
}),

Internally, the plugin now sets an environment variable during the build that indicates to the preview server that the prerender Worker should be used as the entry. This means that the Vite preview server can be used during the build to send requests to the prerender Worker.

An example of usage is included in https://github.com/cloudflare/workers-sdk/blob/803348985820e61a7e11a554a5633a8cadbe3751/packages/vite-plugin-cloudflare/playground/prerendering/vite.config.ts.


  • Tests
    • Tests included/updated
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: experimental and should be undocumented for now
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a Wrangler change

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

⚠️ No Changeset found

Latest commit: 8033489

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 18, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11697

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11697

miniflare

npm i https://pkg.pr.new/miniflare@11697

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11697

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11697

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11697

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11697

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11697

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11697

wrangler

npm i https://pkg.pr.new/wrangler@11697

commit: 8033489

@jamesopstad jamesopstad force-pushed the james/prerender-worker branch 4 times, most recently from 01bfc24 to bae5826 Compare December 18, 2025 20:53
@matthewp
Copy link

We have this working in withastro/astro#15077

This change works for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants