Use remote build cache providers
Edit this page
Accelerate local development by caching and reusing builds from a remote provider.
Remote build caching is an experimental feature that speeds up npx expo run:[android|ios]
by caching builds remotely, based on the project fingerprint.
When you run npx expo run:[android|ios]
, it checks if a build with a matching fingerprint exists, then downloads and launches it rather than compiling it again. Otherwise, the project is compiled as usual and then the resulting binary is uploaded to the remote cache for future runs.
Using EAS as a remote build provider
To use the EAS remote build provider plugin, start by installing the eas-build-cache-provider
package as a developer dependency:
-
npx expo install eas-build-cache-provider
Then, update your app.json to include the remoteBuildCache
property and its provider under experiments
:
{
"expo": {
...
"experiments": {
"remoteBuildCache": {
"provider": "eas-build-cache-provider"
}
}
}
}
You can roll your own cache provider by exporting a plugin that implements the following methods:
type RemoteBuildCachePlugin<T = any> = {
/**
* Try to fetch an existing build. Return its URL or null if missing.
*/
resolveRemoteBuildCache(props: ResolveRemoteBuildCacheProps, options: T): Promise<string | null>;
/**
* Upload a new build binary. Return its URL or null on failure.
*/
uploadRemoteBuildCache(props: UploadRemoteBuildCacheProps, options: T): Promise<string | null>;
/**
* (Optional) Customize the fingerprint hash algorithm.
*/
calculateFingerprintHash?: (
props: CalculateFingerprintHashProps,
options: T
) => Promise<string | null>;
};
type ResolveRemoteBuildCacheProps = {
projectRoot: string;
platform: 'android' | 'ios';
runOptions: RunOptions;
fingerprintHash: string;
};
type UploadRemoteBuildCacheProps = {
projectRoot: string;
buildPath: string;
runOptions: RunOptions;
fingerprintHash: string;
platform: 'android' | 'ios';
};
type CalculateFingerprintHashProps = {
projectRoot: string;
platform: 'android' | 'ios';
runOptions: RunOptions;
};
A reference implementation using GitHub Releases to cache builds can be found at in the Remote Build Cache Provider Example
Creating a custom remote build provider
Start by creating a provider directory for writing the provider plugin in TypeScript and add a provider.plugin.js file in the project root, which will be the plugin's entry point.
1
2
Create a provider/src/index.ts
file for your plugin
import { RemoteBuildCachePlugin } from '@expo/config';
const plugin: RemoteBuildCachePlugin {
resolveRemoteBuildCache: () => {
console.log('Searching for remote builds...')
return null;
},
uploadRemoteBuildCache: () => {
console.log('Uploading build to remote...')
return null;
},,
};
export default plugin;
3
4
5
6
Passing custom options
To inject custom options to your plugin you can use the options
field and it will be forwarded as the second parameter of your custom functions. To do so modify the remoteBuildCache
field in example/app.json as shown below:
{
"expo": {
...
"experiments": {
"remoteBuildCache": {
"provider": "./provider.plugin.js",
"options": {
"myCustomKey": "XXX-XXX-XXX"
}
}
}
}
}