KV / Vectorize / AI
readyProvision and bind Cloudflare KV namespaces, Vectorize indexes (with metadata indexes), D1 databases, and Workers AI + AI Gateway directly in nextdeploy.yml.
Source reference: cli/internal/serverless/cloudflare/bindings.go, cli/internal/serverless/cloudflare/vectorize.go, cli/internal/serverless/cloudflare/aigateway.go
Cloudflare KV
Use KV for edge rate limiting, session metadata, and cross-isolate revalidateTag() invalidation (NEXTCOMPILE_CACHE):
version: "1.0"
target_type: serverless
app:
name: my-app
domain: app.example.com
environment: production
serverless:
provider: cloudflare
cloudflare:
compatibility_date: "2026-05-01"
compatibility_flags:
- nodejs_compat
resources:
kv:
- name: rate-limit-kv
binding: RATE_LIMIT
- name: nextcompile-cache-kv
binding: NEXTCOMPILE_CACHE
When NEXTCOMPILE_CACHE is bound, NextDeploy's CloudflareCacheHandler automatically propagates revalidateTag() timestamps across every Cloudflare edge isolate worldwide.
[!NOTE] KV Write Limits & Edge Rate Limiting: Cloudflare KV limits updates to 1
PUTper second per key (and 1,000 writes/day on Free plans). NextDeploy's edge guard (guard.mjs) coalesces rate-limitkv.putcalls to once per1,100msper key per isolate viactx.waitUntil(...), catches KV429contention errors, and also supports native Cloudflareratelimitbindings (protection.rate_limit.binding) for high-throughput endpoints.
Workers AI, AI Gateway & Vectorize
Provision a Vectorize index (including filterable metadata indexes) and an AI Gateway, and bind Workers AI + Vectorize in nextdeploy.yml:
version: "1.0"
target_type: serverless
app:
name: my-ai-app
domain: ai.example.com
environment: production
serverless:
provider: cloudflare
cloudflare:
compatibility_date: "2026-05-01"
compatibility_flags:
- nodejs_compat
resources:
vectorize:
- name: docs-embeddings
binding: DOCS_INDEX
dimensions: 768
metric: cosine
metadata_indexes:
- property_name: category
type: string
ai_gateway:
- slug: main-gateway
cache_ttl: 300
collect_logs: true
bindings:
ai:
- name: AI
gateway:
id: main-gateway
Access AI and DOCS_INDEX through globalThis.__nextdeployEnv:
const env = (globalThis as { __nextdeployEnv?: CloudflareEnv }).__nextdeployEnv
const result = await env?.AI.run('@cf/meta/llama-3.1-8b-instruct', {
prompt: 'Summarize NextDeploy in one sentence.',
})