Files

@vinext/cloudflare

Cloudflare deployment tools and runtime adapters for vinext.

This package provides Cloudflare-specific cache and image backends for vinext:

  • kvDataAdapter() (@vinext/cloudflare/cache/kv-data-adapter) — backs the data cache (fetch, "use cache", unstable_cache) with a Workers KV namespace.
  • cdnAdapter() (@vinext/cloudflare/cache/cdn-adapter) — delegates page-level ISR serving and revalidation to Cloudflare Workers Cache. This is opt-in and requires Workers Cache to be enabled in Wrangler config.
  • imagesOptimizer() (@vinext/cloudflare/images/images-optimizer) — backs next/image transformations with a Cloudflare Images binding.

Usage

Declare the adapters on the vinext() plugin in your Vite config:

import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
import { imagesOptimizer } from "@vinext/cloudflare/images/images-optimizer";

export default defineConfig({
  plugins: [
    vinext({
      cache: {
        data: kvDataAdapter(), // KV-backed data cache (binding: VINEXT_KV_CACHE)
      },
      images: { optimizer: imagesOptimizer() }, // Cloudflare Images binding: IMAGES
    }),
    cloudflare(),
  ],
});

Workers Cache

cdnAdapter() is optional. Only configure it when Workers Cache is enabled in wrangler.jsonc:

{
  "cache": {
    "enabled": true,
  },
}
import { cdnAdapter } from "@vinext/cloudflare/cache/cdn-adapter";

vinext({ cache: { cdn: cdnAdapter() } });

Deploy

Deploy Cloudflare Workers projects with the package CLI:

npx @vinext/cloudflare deploy

With Vite+, use vpx @vinext/cloudflare deploy, or vp exec vinext-cloudflare deploy when running the locally installed bin.