cached-middleware-fetch-next
JSON →A Next.js fetch wrapper for edge middleware that uses Vercel Runtime Cache as its caching backend. Current stable version is 0.8.2. It provides a drop-in replacement for the native fetch API, mimicking Next.js's Data Cache behavior in edge middleware where standard Data Cache is unavailable. Features include support for Next.js fetch options (cache, next.revalidate, next.tags), SWR (Stale-While-Revalidate) caching strategy via waitUntil(), automatic cache key generation including body for POST/PUT, GraphQL query caching, cache status headers, and graceful fallback. Requires @vercel/functions >=2.2.0 and next >=14.0.0 as peer dependencies, and Node >=18.0.0. Ships TypeScript types. The library addresses a known limitation of Next.js on Vercel (https://github.com/vercel/next.js/pull/80378) where fetch caching is not available in edge middleware.