Skip to content
Cloudflare Docs

Local Development

Queues support local development workflows using Wrangler, the command-line interface for Workers. Wrangler runs the same version of Queues as Cloudflare runs globally.

Prerequisites

To develop locally with Queues, you will need:

  • Wrangler v3.1.0 or later.

  • Node.js version of 18.0.0 or later. Consider using a Node version manager like Volta or nvm to avoid permission issues and change Node versions.

  • If you are new to Queues and/or Cloudflare Workers, refer to the Queues tutorial to install wrangler and deploy their first Queue.

Start a local development session

Open your terminal and run the following commands to start a local development session:

Terminal window
npx wrangler@latest dev
------------------
Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
Your worker has access to the following bindings:
- Queues: <QUEUE-NAME>

Local development sessions create a standalone, local-only environment that mirrors the production environment Queues runs in so you can test your Workers before you deploy to production.

Refer to the wrangler dev documentation to learn more about how to configure a local development session.

Separating producer & consumer Workers

Wrangler supports running multiple Workers simultaneously with a single command. If your architecture separates the producer and consumer into distinct Workers, you can use this functionality to test the entire message flow locally.

For example, if your project has the following directory structure:

producer-worker/
├── wrangler.jsonc
├── index.ts
└── consumer-worker/
├── wrangler.jsonc
└── index.ts

You can start development servers for both workers with the following command:

Terminal window
npx wrangler@latest dev -c wrangler.jsonc -c consumer-worker/wrangler.jsonc --persist-to .wrangler/state

When the producer Worker sends messages to the queue, the consumer Worker will automatically be invoked to handle them.

Known Issues

  • Queues does not support Wrangler remote mode (wrangler dev --remote).
OSZAR »