Package Exports
- @vercel/remote
- @vercel/remote/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@vercel/remote) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Vercel Remote Caching
An API for remote artifact caching on Vercel.com.
Remote Computation Caching (or just Remote Caching) is a feature of advanced build tools like Turborepo, Bazel, and Buck to cache compiled computations and code artifacts in the cloud with the hope of recycling them across machines to reduce overall build/computation time. The key idea is that you "never recompute work that’s already been done before."
Through Vercel's Remote Caching API, teams can leverage this advanced primitive without needing to think about hosting, infrastructure, or maintenance.
This repository holds the source code to the Vercel Remote Caching SDK as well as examples of build systems that leverage it. For those looking to integrate their build systems with Vercel Remote Caching, you've come to the right place. The SDK is a thin layer over our existing REST API with some additional useful behaviors. Otherwise, if you're looking for examples of build systems and tools that integrate with Vercel Remote Caching, checkout the examples list.
Table of Contents
Examples
Vercel Remote Caching SDK
npm install @vercel/remoteIn your build system....
import 'fs' from 'fs-extra'
import { createClient } from '@vercel/remote'
const remote = createClient('access_token', {
teamSlug: 'my-team',
});
async function getArtifact(key) {
const exists = await remote.exists(key);
if (!exists) {
return false
}
const buf = await remote.get(key)
await fs.writeFile(key, buf)
return true
}
async function putArtifact(key, buf) {
await remote.put(key, buf)
}Authentication
@todo
- Personal access token
VERCEL_ARTIFACTS_TOKEN+VERCEL_ARTIFACTS_OWNER(this could/should potentially be set automatically when run on Vercel?)
API Reference
RemoteClient(token: string, opt: Options)
const remote = new RemoteClient('access_token', {
teamSlug: 'my-team',
});Options
teamSlug- Vercel slug or team IDproject- The project ID, useful for attribution
Methods
remote.exists(key: string): Promise<boolean>
Returns true if an artifact exists in the remote cache.
const exists = await remote.exists('6079a2819459d70b');remote.get(key: string)
Returns an artifact from the remote cache
const buf = await remote.get('6079a2819459d70b');remote.put(key: string, file: Buffer, meta: Meta)
Uploads an artifact to the remote cache
await remote.put('6079a2819459d70b', buf, {
time: 8030,
});Errors
@todo