1import { KvNamespace } from "@alchemy.run/cloudflare-runtime/core/bindings";
2import * as Options from "@alchemy.run/cloudflare-test-tools/e2e/Options";
3import { make } from "@alchemy.run/frontend-frameworks/nextjs";
4import { kCurrentWorker } from "miniflare";
5
6/**
7 * The writable-ISR configuration: KV-backed incremental cache
8 * (`NEXT_INC_CACHE_KV`) + Durable Object revalidation queue
9 * (`NEXT_CACHE_DO_QUEUE` on the same-script `DOQueueHandler` class) +
10 * the `WORKER_SELF_REFERENCE` self service binding.
11 *
12 * The dev (workerd) runtime auto-wires the DO queue and self-reference:
13 * `@alchemy.run/frontend-frameworks/nextjs` detects the `DOQueueHandler` export in the
14 * built worker. The preview (miniflare) config declares them explicitly.
15 */
16export default Options.make({
17 framework: (options) => make({ ...options, nextjs: { cache: "kv" } }),
18 vite: {
19 compatibilityDate: "2026-05-12",
20 compatibilityFlags: ["nodejs_compat", "global_fetch_strictly_public"],
21 worker: {
22 name: "fixtures-nextjs-isr",
23 bindings: [
24 KvNamespace.local({ binding: "NEXT_INC_CACHE_KV" }),
25 KvNamespace.local({ binding: "NEXT_TAG_CACHE_KV" }),
26 ],
27 },
28 },
29 miniflare: {
30 name: "fixtures-nextjs-isr",
31 compatibilityDate: "2026-05-12",
32 compatibilityFlags: ["nodejs_compat", "global_fetch_strictly_public"],
33 kvNamespaces: ["NEXT_INC_CACHE_KV", "NEXT_TAG_CACHE_KV"],
34 serviceBindings: { WORKER_SELF_REFERENCE: kCurrentWorker },
35 durableObjects: {
36 NEXT_CACHE_DO_QUEUE: { className: "DOQueueHandler", useSQLite: true },
37 },
38 assets: {
39 binding: "ASSETS",
40 routerConfig: {
41 has_user_worker: true,
42 invoke_user_worker_ahead_of_assets: true,
43 },
44 assetConfig: {
45 html_handling: "none",
46 not_found_handling: "none",
47 },
48 },
49 },
50});