{"id":45551,"library":"next-quick-cache","title":"next-quick-cache","description":"A lightweight TypeScript cache library (v3.1.10) with stale-while-revalidate support, meant as a drop-in replacement for Next.js unstable_cache that works in any JavaScript environment. Key differentiators: request deduplication, configurable stale behavior (serve stale or wait), tag-based on-demand revalidation, optional disk persistence. Released under MIT license, actively maintained with regular updates. Ships TypeScript types.","status":"active","version":"3.1.10","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","cache","typescript","stale-while-revalidate","background-revalidation","next.js","unstable_cache"],"install":[{"cmd":"npm install next-quick-cache","lang":"bash","label":"npm"},{"cmd":"yarn add next-quick-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add next-quick-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional peer dependency for Next.js integration; core caching works without Next.js.","package":"next","optional":true}],"imports":[{"note":"ESM-only package; CommonJS require will not work. Use ESM import only.","wrong":"const quick_cache = require('next-quick-cache')","symbol":"quick_cache","correct":"import { quick_cache } from 'next-quick-cache'"},{"note":"Standalone revalidateTag, not tied to Next.js internals. Can be used outside Next.js.","wrong":"import { revalidateTag } from 'next/cache'","symbol":"revalidateTag","correct":"import { revalidateTag } from 'next-quick-cache'"},{"note":"Type import for configuration options. Use with TypeScript.","symbol":"CacheOption","correct":"import type { CacheOption } from 'next-quick-cache'"}],"quickstart":{"code":"import { quick_cache } from 'next-quick-cache';\n\nconst getCachedUser = quick_cache(\n  async (id: string) => {\n    // Simulate fetching user data\n    return { id, name: 'John Doe' };\n  },\n  ['user'],\n  {\n    revalidate: 60,\n    tags: ['users'],\n  }\n);\n\nasync function main() {\n  const user = await getCachedUser('123');\n  console.log(user);\n}\n\nmain();","lang":"typescript","description":"Demonstrates basic usage: create a cached async function with 60-second revalidation and tag, then call it."},"warnings":[{"fix":"Use ESM imports: `import { quick_cache } from 'next-quick-cache'`","message":"In v3.0.0, the package switched to ESM-only. CommonJS ('require') will throw an error.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Explicitly set `serveStale: true` if you want stale data while revalidating, or keep default (true) as per current docs.","message":"The `serveStale` option default changed from true to false in v2.0.0? Actually current version defaults to true. Check docs for version-specific behavior.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use the same string array (e.g., ['user']) for the same cached function to ensure cache hits.","message":"The cache key parts array must be consistent across calls. Changing the string array will create a new cache entry.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Enable `persist: true` option for disk caching to share cache across processes.","message":"Do not rely on `quick_cache` for high-security data cache invalidation; it uses in-memory store by default and may not be suitable for multi-server environments without disk persistence.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always specify `revalidate: <seconds>` to avoid unexpected caching behavior.","message":"The `revalidate` option is required. If omitted, it defaults to 0 (no caching? Actually defaults to 0 meaning no revalidation? Read docs.)","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'activ':59 'background':75 'background-revalid':74 'base':47 'behavior':40 'cach':4,8,27,68,79 'configur':38 'dedupl':37 'demand':50 'differenti':35 'disk':53 'drop':21 'drop-in':20 'environ':33 'javascript':32,67 'key':34 'librari':9 'licens':58 'lightweight':6 'maintain':60 'meant':17 'mit':57 'next':2 'next-quick-cach':1 'next.js':25,77 'on-demand':48 'option':52 'persist':54 'quick':3 'regular':62 'releas':55 'replac':23 'request':36 'revalid':15,51,73,76 'serv':41 'ship':64 'stale':13,39,42,71 'stale-while-revalid':12,70 'support':16 'tag':46 'tag-bas':45 'type':66 'typescript':7,65,69 'unstabl':26,78 'updat':63 'v3.1.10':10 'wait':44 'work':29","created_at":"2026-06-07T12:55:34.332490+00:00","updated_at":"2026-06-07T12:55:34.332490+00:00","problems":[{"fix":"Switch to `import { quick_cache } from 'next-quick-cache'` and ensure your project is configured for ESM (e.g., \"type\": \"module\" in package.json or use .mjs extension).","cause":"Using CommonJS require with ESM-only package","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use named import: `import { quick_cache } from 'next-quick-cache'`","cause":"Incorrect import or trying to use default export","error":"TypeError: quick_cache is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"next-quick-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}