Skip to content

yunsii/starter-vike-cloudflare-react-worker

Repository files navigation

Cloudflare Workers with:

Docs

See vike.dev/cloudflare-workers.

Run

git clone [email protected]: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

Universal fetch()

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.