Metro is the JavaScript bundler for React Native applications. The metro-cache package provides caching layers for Metro, enabling faster builds by storing and retrieving previously computed results. Version 0.84.4 is the current stable release. It is updated frequently alongside Metro releases. Key differentiators include multiple cache backends (file, HTTP, etc.) and integration with Metro's build pipeline. It is part of the official Metro monorepo maintained by Meta.
npm install metro-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a FileStore and use CacheStore to set and get cached values.
Ensure you use await or .then() when calling set and get.
Always provide an explicit root directory that exists and is writable.
Consider implementing a custom store using the CacheStore interface or use FileStore with a shared filesystem.
Always use string keys, preferably hashed or serialized.
Create the directory before initializing FileStore or set root to an existing directory.
Call cache.set with await or handle the promise.
Convert key to string, e.g., JSON.stringify or toString().