Skip to content

Commit 1846f1e

Browse files
dinasaur404dcpena
andauthored
Workers for Platforms docs: Improved dispatch Worker description (#19232)
* docs: improve dispatch Worker description * Update src/content/docs/cloudflare-for-platforms/workers-for-platforms/get-started/configuration.mdx Co-authored-by: Denise Peña <[email protected]> * Update src/content/docs/cloudflare-for-platforms/workers-for-platforms/get-started/configuration.mdx Co-authored-by: Denise Peña <[email protected]> * Update src/content/docs/cloudflare-for-platforms/workers-for-platforms/get-started/configuration.mdx Co-authored-by: Denise Peña <[email protected]> --------- Co-authored-by: Denise Peña <[email protected]>
1 parent 824fbea commit 1846f1e

File tree

1 file changed

+21
-4
lines changed
  • src/content/docs/cloudflare-for-platforms/workers-for-platforms/get-started

1 file changed

+21
-4
lines changed

src/content/docs/cloudflare-for-platforms/workers-for-platforms/get-started/configuration.mdx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,33 @@ To upload and deploy the user Worker to the dispatch namespace, running the foll
6767
npx wrangler deploy --dispatch-namespace testing
6868
```
6969

70-
### 4. Create a dispatch Worker
70+
### 4. Create a dynamic dispatch Worker
7171

72-
[Dispatch Workers](/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dynamic-dispatch-worker) are used to execute user Workers from the dispatch namespace. You will now create a dispatch Worker and add logic it needs to route to the user Worker created in step 2.
72+
A [dynamic dispatch Worker](/cloudflare-for-platforms/workers-for-platforms/reference/how-workers-for-platforms-works/#dynamic-dispatch-worker) is a specialized routing Worker that directs incoming requests to the appropriate user Workers in your dispatch namespace. Instead of using [Workers Routes](/workers/configuration/routing/routes/), dispatch Workers let you programmatically control request routing through code.
73+
74+
#### Why use a dynamic dispatch Worker?
75+
76+
* **Scale**: Perfect for routing thousands or millions of hostnames to different Workers, without needing to rely on [Workers Routes](/workers/configuration/routing/routes/)
77+
* **Custom routing logic**: Write code to determine exactly how requests should be routed. For example:
78+
* Map hostnames directly to specific Workers
79+
* Route requests based on subdomains
80+
* Use request metadata or headers for routing decisions
81+
82+
* **Add platform functionality**: Build in additional features at the routing layer.
83+
* Run authentication checks before requests reach user Workers
84+
* Sanitize incoming requests
85+
* Attach useful context like user IDs or account information
86+
* Transform requests or responses as needed
87+
88+
**To create your dynamic dispatch Worker:**
7389

7490
Navigate up a level from your user Worker's project directory:
7591

7692
```sh
7793
cd ..
7894
```
7995

80-
Create your dispatch Worker. In this example, the dispatch Worker is called `my-dispatcher`.
96+
Create your dynamic dispatch Worker. In this example, the dispatch Worker is called `my-dispatcher`.
8197

8298
<PackageManagers type="create" pkg="cloudflare@latest" args={"my-dispatcher"} />
8399

@@ -121,8 +137,9 @@ export default {
121137
},
122138
};
123139
```
140+
This example shows a simple dynamic dispatch Worker that routes all requests to a single user Worker. For more advanced routing patterns, you could route based on hostname, path, custom metadata, or other request properties.
124141

125-
Deploy your dispatch Worker:
142+
Deploy your dynamic dispatch Worker:
126143

127144
```sh
128145
npx wrangler deploy

0 commit comments

Comments
 (0)