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
Copy file name to clipboardExpand all lines: pages/cloudflare/bindings.mdx
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,40 @@ 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 [getting started](/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 local emulations of the bindings are 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 remote resources associated to your
67
+
Cloudflare account.
68
+
69
+
Remote bindings are currently experimental and can be enabled it in your `next.config.ts` file:
70
+
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
+
82
+
<Callout>
83
+
Note that remote bindings will also be used during build, this can be very useful for example when using
84
+
features such [ISR](https://nextjs.org/docs/app/guides/incremental-static-regeneration) so that read
85
+
production data can be used for the site's static generation
86
+
</Callout>
87
+
54
88
## Other Cloudflare APIs (`cf`, `ctx`)
55
89
56
90
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