next-build-cache
Next Build Cache is a ultra simple file-based caching solution built for usage during the Next.js build process to pass data from getStaticPaths
to getStaticProps
without re-fetching data.
The Problem:
Next.js calls separate workers for getStaticPaths
and getStaticProps
, which means that data cannot be cached in-memory to re-use in getStaticProps
.
Installation
Using npm
$ npm i next-build-cache
Using yarn
$ yarn next-build-cache
Usage
import { accessCache } from 'next-build-cache';
const cache = accessCache('build.cache');
await cache.put('mykey', 'myvalue', 1000);
await cache.get('mykey');
License
MIT