Local development
To test your Dispatch Worker, user Worker and Outbound Worker before deploying to production, you can use Wrangler for development and testing.
Support for Workers for Platforms with wrangler dev
in local mode is experimental and may change in the future. Use the prerelease branch: wrangler@dispatch-namespaces-dev
to try Workers for Platforms locally.
For setup, select the following options:
- For What would you like to start with?, choose
Hello World example
. - For Which template would you like to use?, choose
Hello World Worker`
. - For Which language do you want to use?, choose
JavaScript`
. - For Do you want to use git for version control?, choose
Yes
. - For Do you want to deploy your application?, choose
No
(we will be making some changes before deploying).
Then, move into the newly created directory:
Update the src/index.js
file for customer-worker-1:
Update the wrangler.toml
file for customer-worker-1 and add the dispatch namespace:
For setup, select the following options:
- For What would you like to start with?, choose
Hello World example
. - For Which template would you like to use?, choose
Hello World Worker`
. - For Which language do you want to use?, choose
JavaScript`
. - For Do you want to use git for version control?, choose
Yes
. - For Do you want to deploy your application?, choose
No
(we will be making some changes before deploying).
Then, move into the newly created directory:
Update the src/index.js
file for dispatch-worker:
Update the wrangler.toml
file for dispatch-worker and add the dispatch namespace binding:
For setup, select the following options:
- For What would you like to start with?, choose
Hello World example
. - For Which template would you like to use?, choose
Hello World Worker`
. - For Which language do you want to use?, choose
JavaScript`
. - For Do you want to use git for version control?, choose
Yes
. - For Do you want to deploy your application?, choose
No
(we will be making some changes before deploying).
Then, move into the newly created directory:
Update the src/index.js
file for outbound-worker:
In separate terminals, start a local dev session for each of your Workers.
For your dispatcher Worker:
For your outbound Worker:
And for your user Worker:
Send a request to your dispatcher Worker: