Back to Qwik

README

starters/adapters/cloudflare-workers/README.md

1.7.11.7 KB
Original Source

Cloudflare Workers

Cloudflare's wrangler CLI can be used to preview a production build locally. To start a local server, run:

npm run serve

Then visit http://localhost:8787/

Deployments

Cloudflare Workers can be deployed using the Wrangler CLI.

If you don't already have an account, then create a Cloudflare account here.

Once authenticated, you can deploy your Worker:

npm run deploy

Configuration

The wrangler.jsonc file contains your Worker configuration. Key settings include:

  • name: Your Worker's name
  • main: Path to your Worker script (default: ./dist/_worker.js)
  • compatibility_date: The date used for compatibility with the Workers runtime
  • assets: Configuration for serving static assets
  • bindings: Resources your Worker can interact with (KV, R2, D1, etc.)

After adding any binding, use this command to regenerate the worker-configuration.d.ts file

npm run cf-typegen

For more details, see the Wrangler configuration documentation.

Bindings

Cloudflare Workers can interact with various Cloudflare resources through bindings:

  • KV: Key-value storage
  • R2: Object storage
  • D1: SQL database
  • Durable Objects: Strongly consistent storage
  • Queues: Message queues
  • AI: AI inference

Configure bindings in your wrangler.jsonc file. See the bindings documentation for more information.