By pre-rendering our pages, we can remove the need for a Node.js server. We can then deploy our app to any static host, such as Cloudflare Pages.
If we want Cloudflare Pages to build our app for us, vite-plugin-ssr
requires Node.js >=12.19.0
and we may need to change Cloudflare Pages' default Node.js version.
If we don't deploy our app at the URL root /
, we can change our app's Base URL.
In general, we can choose between following deploy strategies:
dist/client/
to the static host.dist/client/
to the static host.The
$ vite build
command generates a directorydist/client/
that contains all our static assets.We can locally try our deploy with serve by running
$ serve dist/client/
.
With wrangler v2, we can deploy a Cloudflare Worker (server code) along Cloudflare Pages.
See Deploy > Cloudflare Workers > Cloudflare Pages.
Example of using vite-plugin-ssr
with Cloudflare Pages and Cloudflare Workers: