# cached-middleware-fetch-next A Next.js fetch wrapper for edge middleware that uses Vercel Runtime Cache as its caching backend. ## Overview This library provides a drop-in replacement for the native fetch API that mimics Next.js's Data Cache behavior in edge middleware environments where the standard Data Cache is not available. It implements SWR (Stale-While-Revalidate) caching using Vercel's Runtime Cache and waitUntil() for background refresh. ## Key Features - 🚀 Drop-in replacement for fetch in Next.js middleware - 💾 Uses Vercel Runtime Cache for persistence - 🔄 Supports Next.js fetch options (cache, next.revalidate, next.tags) - ⏱️ SWR (Stale-While-Revalidate) caching strategy using waitUntil() - 🎯 Automatic cache key generation (includes body for proper POST/PUT caching) - 📊 GraphQL Support - Caches POST requests with different queries separately - 📈 Cache Status Headers - Get detailed cache information via response headers - ⚡ Graceful fallback to regular fetch if cache fails - 📦 Lightweight with minimal dependencies ## Installation \`\`\`bash npm install cached-middleware-fetch-next