Cloudflare Workers with:
- Vite
- Vike
- React
react-streaming
- Universal
fetch()
See vike.dev/cloudflare-workers.
git clone git@github.com:vikejs/vike
cd vike/examples/cloudflare-workers-react-full/
npm install
Develop:
For increased development speed, we use an Express.js development server instead of a worker.
npm run dev
Preview the worker locally:
You'll need to login/create a Cloudflare account.
npm run preview
Deploy the worker to Cloudflare:
npm run deploy
Note how we define a fetch function at pageContext.fetch
that is universal: it works for development as well as for the production worker.
The trick is to provide a different fetch()
implementation at worker/ssr.ts and dev-server/index.js.