You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add a section about local access in the Cloudflare bindings documentation
add a section to the Cloudflare bindings documentation, documenting that:
- bindings can be used both for dev and preview
(this is already stated in the get started guide but I believe
that it should also be included in the bindings documentation as well)
- add information on remote bindings and how people can used them
Copy file name to clipboardExpand all lines: pages/cloudflare/bindings.mdx
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,34 @@ This will generate a `d.ts` file and save it to `worker-configuration.d.ts`.
51
51
52
52
To ensure that your types are always up-to-date, make sure to run `wrangler types --env-interface CloudflareEnv` after any changes to your config file.
53
53
54
+
## Local access to bindings
55
+
56
+
As presented in the [relevant getting started section](/cloudflare/get-started#12-develop-locally) your application can be both developed (`next dev`) and
57
+
previewed (`opennextjs-cloudflare preview`) locally, in both cases bindings will be accessible from your application's code.
58
+
59
+
Such bindings are by default local simulation that mimic the behavior of the actual Cloudflare resources.
60
+
61
+
### Remote bindings
62
+
63
+
As mentioned above, by default locally only simulations of the bindings will be used.
64
+
65
+
However [remote bindings](https://developers.cloudflare.com/workers/development-testing/#remote-bindings) can also be
66
+
used, allowing your application code, while still running locally, to connect to real remote resources associated to your
67
+
Cloudflare account.
68
+
69
+
In order to use such remote bindings, since the feature is currently experimental, you'll need to explicitly
70
+
enabled it in your `next.config.mjs` file:
71
+
```diff
72
+
- initOpenNextCloudflareForDev();
73
+
+ initOpenNextCloudflareForDev({
74
+
+ experimental: { remoteBindings: true }
75
+
+ });
76
+
```
77
+
78
+
When the feature is turned on all you then need to do to enable remote mode for any of your bindings
79
+
is to set the `experimental_remote` configuration field to `true`, exactly
80
+
as documented in the [remote bindings documentation](https://developers.cloudflare.com/workers/development-testing/#remote-bindings).
81
+
54
82
## Other Cloudflare APIs (`cf`, `ctx`)
55
83
56
84
You can access context about the incoming request from the [`cf` object](https://developers.cloudflare.com/workers/runtime-apis/request/#the-cf-property-requestinitcfproperties), as well as lifecycle methods from the [`ctx` object](https://developers.cloudflare.com/workers/runtime-apis/context) from the return value of [`getCloudflareContext()`](https://github.com/opennextjs/opennextjs-cloudflare/blob/main/packages/cloudflare/src/api/cloudflare-context.ts):
0 commit comments