RFC: Prerendering with Vite Preview Server #14651
edmundhung
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
React Router's current prerendering directly imports the server bundle:
This requires the build runtime to match the deployment runtime if your code imports runtime-specific modules.
For example, when building with Node.js for Cloudflare Workers deployment, prerendering fails because Node.js can't import
"cloudflare:workers"modules. You can't run the build in the Workers runtime either, since it doesn't support running Vite.Proposed Solution
Use Vite's preview server instead of directly importing the server bundle.
This decouples the build environment from the target runtime:
No API changes - prerendering continues to work the same way from a user perspective. But we can start with an unstable flag for the community to test:
Benefits
Implementation
Full implementation PR available at: #14650
Main changes:
Trade-offs
vite previewsupport #14507)Beta Was this translation helpful? Give feedback.
All reactions