Skip to content

Commit 24a8237

Browse files
use the new defineCloudflareConfig utility the Cloudflare get-started configuration step
1 parent 9cd75ea commit 24a8237

File tree

2 files changed

+24
-51
lines changed

2 files changed

+24
-51
lines changed

pages/cloudflare/caching.mdx

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,21 @@ In your project's OpenNext config, enable the KV cache and set up a queue.
5353

5454
The memory queue will send revalidation requests to a page when needed, and offers support for de-duplicating requests on a per-isolate basis. There might still be duplicate requests under high traffic or across regions.
5555

56+
<Callout type="warning">
57+
The memory queue provided by `@opennextjs/cloudflare` is not fully suitable for production deployments, you
58+
can use it at your own risk!
59+
</Callout>
60+
5661
```ts
5762
// open-next.config.ts
58-
import incrementalCache from "@opennextjs/cloudflare/kv-cache";
63+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
64+
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
5965
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
6066

61-
const config: OpenNextConfig = {
62-
default: {
63-
override: {
64-
// ...
65-
incrementalCache: () => incrementalCache,
66-
queue: () => memoryQueue,
67-
},
68-
},
69-
// ...
70-
};
71-
72-
export default config;
67+
export default defineCloudflareConfig({
68+
incrementalCache: kvIncrementalCache,
69+
queue: memoryQueue,
70+
});
7371
```
7472

7573
<Callout>
@@ -126,21 +124,16 @@ In your project's OpenNext config, enable the KV cache and set up a queue. The q
126124

127125
```ts
128126
// open-next.config.ts
129-
import tagCache from "@opennextjs/cloudflare/d1-tag-cache";
130-
import incrementalCache from "@opennextjs/cloudflare/kv-cache";
127+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
128+
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
129+
import d1TagCache from "@opennextjs/cloudflare/d1-tag-cache";
131130
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
132131

133-
const config: OpenNextConfig = {
134-
default: {
135-
override: {
136-
// ...
137-
incrementalCache: () => incrementalCache,
138-
queue: () => memoryQueue,
139-
tagCache: () => tagCache,
140-
},
141-
},
142-
// ...
143-
};
132+
export default defineCloudflareConfig({
133+
incrementalCache: kvIncrementalCache,
134+
tagCache: d1TagCache,
135+
queue: memoryQueue,
136+
});
144137
```
145138

146139
##### 4. Initialise the cache during deployments

pages/cloudflare/get-started.mdx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,12 @@ You can create one yourself in the root directory of your Next.js app with the n
8787
Add a [`open-next.config.ts`](https://opennext.js.org/aws/config) file to the root directory of your Next.js app:
8888

8989
```ts
90-
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js";
91-
import cache from "@opennextjs/cloudflare/kv-cache";
92-
93-
const config: OpenNextConfig = {
94-
default: {
95-
override: {
96-
wrapper: "cloudflare-node",
97-
converter: "edge",
98-
// set `incrementalCache` to "dummy" to disable KV cache
99-
incrementalCache: async () => cache,
100-
tagCache: "dummy",
101-
queue: "dummy",
102-
},
103-
},
104-
105-
middleware: {
106-
external: true,
107-
override: {
108-
wrapper: "cloudflare-edge",
109-
converter: "edge",
110-
proxyExternalRequest: "fetch",
111-
},
112-
},
113-
};
90+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
91+
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
11492

115-
export default config;
93+
export default defineCloudflareConfig({
94+
incrementalCache: kvIncrementalCache,
95+
});
11696
```
11797

11898
<Callout>

0 commit comments

Comments
 (0)