Registry / devops / next-quick-cache

next-quick-cache

JSON →
library3.1.10jsnpmunverified

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.

npm install next-quick-cache
INSTALL
IMPORT
SIG · NEXT-QUICK-CACHE
N
next-quick-cache
devopsjavascriptv3.1.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

quick_cache
✓ import { quick_cache } from 'next-quick-cache'
✗ const quick_cache = require('next-quick-cache')
ESM-only package; CommonJS require will not work. Use ESM import only.
revalidateTag
✓ import { revalidateTag } from 'next-quick-cache'
✗ import { revalidateTag } from 'next/cache'
Standalone revalidateTag, not tied to Next.js internals. Can be used outside Next.js.
CacheOption
✓ import type { CacheOption } from 'next-quick-cache'
Type import for configuration options. Use with TypeScript.

Demonstrates basic usage: create a cached async function with 60-second revalidation and tag, then call it.

import { quick_cache } from 'next-quick-cache'; const getCachedUser = quick_cache( async (id: string) => { // Simulate fetching user data return { id, name: 'John Doe' }; }, ['user'], { revalidate: 60, tags: ['users'], } ); async function main() { const user = await getCachedUser('123'); console.log(user); } main();
Debug
Known issues
breakingIn v3.0.0, the package switched to ESM-only. CommonJS ('require') will throw an error.
fix
Use ESM imports: `import { quick_cache } from 'next-quick-cache'`
affects: >=3.0.0
deprecatedThe `serveStale` option default changed from true to false in v2.0.0? Actually current version defaults to true. Check docs for version-specific behavior.
fix
Explicitly set `serveStale: true` if you want stale data while revalidating, or keep default (true) as per current docs.
affects: >=1.0.0
gotchaThe cache key parts array must be consistent across calls. Changing the string array will create a new cache entry.
fix
Use the same string array (e.g., ['user']) for the same cached function to ensure cache hits.
affects: >=1.0.0
gotchaDo 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.
fix
Enable `persist: true` option for disk caching to share cache across processes.
affects: >=1.0.0
deprecatedThe `revalidate` option is required. If omitted, it defaults to 0 (no caching? Actually defaults to 0 meaning no revalidation? Read docs.)
fix
Always specify `revalidate: <seconds>` to avoid unexpected caching behavior.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using CommonJS require with ESM-only package
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).
TypeError: quick_cache is not a function
Incorrect import or trying to use default export
fix
Use named import: `import { quick_cache } from 'next-quick-cache'`
Upgrade
Version history
3.1.10latest on npm
Audit
Dependencies
nextoptionalOptional peer dependency for Next.js integration; core caching works without Next.js.
Agent activity
7 hits · last 30 days
node
6
Resources
next-quick-cache — npm install next-quick-cache · libregistry