Skip to content

Commit 3b4fc20

Browse files
authored
Document remote bindings + environments (#25268)
* Document remote bindings + environments * Update index.mdx
1 parent ec74c7d commit 3b4fc20

File tree

1 file changed

+21
-16
lines changed
  • src/content/docs/workers/development-testing

1 file changed

+21
-16
lines changed

src/content/docs/workers/development-testing/index.mdx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,9 @@ During local development, your Worker code interacts with these bindings using t
9595

9696
When remote bindings are configured, your Worker still **executes locally**, only the underlying resources your bindings connect to change. For all bindings marked with `remote: true`, Miniflare will route its operations (such as `env.MY_KV.put()`) to the deployed resource. All other bindings not explicitly configured with `remote: true` continue to use their default local simulations.
9797

98-
### Targeting preview resources
98+
### Integration with environments
9999

100-
To protect production data, you can create and specify preview resources in your [Wrangler configuration](/workers/wrangler/configuration/), such as:
101-
102-
- [Preview namespaces for KV stores](/workers/wrangler/configuration/#kv-namespaces):`preview_id`.
103-
- [Preview buckets for R2 storage](/workers/wrangler/configuration/#r2-buckets): `preview_bucket_name`.
104-
- [Preview database IDs for D1](/workers/wrangler/configuration/#d1-databases): `preview_database_id`
105-
106-
If preview configuration is present for a binding, setting `remote: true` will ensure that remote bindings connect to that designated remote preview resource.
100+
Remote Bindings work well together with [Workers Environments](/workers/wrangler/environments). To protect production data, you can create a development or staging environment and specify different resources in your [Wrangler configuration](/workers/wrangler/configuration/) than you would use for production.
107101

108102
**For example:**
109103

@@ -114,20 +108,31 @@ If preview configuration is present for a binding, setting `remote: true` will e
114108
"name": "my-worker",
115109
"compatibility_date": "$today",
116110

117-
"r2_buckets": [
118-
{
119-
"bucket_name": "screenshots-bucket",
120-
"binding": "screenshots_bucket",
121-
"preview_bucket_name": "preview-screenshots-bucket",
122-
"remote": true,
111+
"env": {
112+
"production": {
113+
"r2_buckets": [
114+
{
115+
"bucket_name": "screenshots-bucket",
116+
"binding": "screenshots_bucket",
117+
},
118+
],
123119
},
124-
],
120+
"staging": {
121+
"r2_buckets": [
122+
{
123+
"bucket_name": "preview-screenshots-bucket",
124+
"binding": "screenshots_bucket",
125+
"remote": true,
126+
},
127+
],
128+
},
129+
},
125130
}
126131
```
127132

128133
</WranglerConfig>
129134

130-
Running `wrangler dev` with the above configuration means that:
135+
Running `wrangler dev -e staging` (or `CLOUDFLARE_ENV=staging vite dev`) with the above configuration means that:
131136

132137
- Your Worker code runs locally
133138
- All calls made to `env.screenshots_bucket` will use the `preview-screenshots-bucket` resource, rather than the production `screenshots-bucket`.

0 commit comments

Comments
 (0)