Cloudflare R2 Storage
Store your Hot Updater bundles in Cloudflare R2.
Installation
npm install @hot-updater/cloudflareSetup
The easiest way to set up your backend is using the init command:
npx hot-updater initThis interactive command will guide you through the setup process. For details on what the init command does, see the Cloudflare documentation.
For manual configuration, use the settings below.
Create R2 S3-compatible credentials from the Cloudflare R2 API token page or follow the Cloudflare R2 API token guide.
Configuration
interface R2S3StorageConfig {
accountId: string;
bucketName: string;
credentials: {
accessKeyId: string;
secretAccessKey: string;
};
basePath?: string;
}The previous Wrangler configuration remains available for backward
compatibility. It supports only deploy-time (node) operations:
interface R2WranglerStorageConfig {
accountId: string;
bucketName: string;
cloudflareApiToken: string;
basePath?: string;
credentials?: never;
}Usage
import { r2Storage } from "@hot-updater/cloudflare";
import { defineConfig } from "hot-updater";
export default defineConfig({
storage: r2Storage({
accountId: process.env.HOT_UPDATER_CLOUDFLARE_ACCOUNT_ID!,
bucketName: process.env.HOT_UPDATER_CLOUDFLARE_R2_BUCKET_NAME!,
credentials: {
accessKeyId: process.env.HOT_UPDATER_CLOUDFLARE_R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.HOT_UPDATER_CLOUDFLARE_R2_SECRET_ACCESS_KEY!,
},
}),
// ... other config
});Runtime Usage
With S3-compatible credentials, the root r2Storage export implements both the
deploy-time (node) and self-hosted (runtime) profiles:
import { r2Storage } from "@hot-updater/cloudflare";
import { createHotUpdater } from "@hot-updater/server";
const storage = r2Storage({
accountId: process.env.HOT_UPDATER_CLOUDFLARE_ACCOUNT_ID!,
bucketName: process.env.HOT_UPDATER_CLOUDFLARE_R2_BUCKET_NAME!,
credentials: {
accessKeyId: process.env.HOT_UPDATER_CLOUDFLARE_R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.HOT_UPDATER_CLOUDFLARE_R2_SECRET_ACCESS_KEY!,
},
});
export const hotUpdater = createHotUpdater({
storages: [storage],
// ... other options
});Cloudflare Worker deployments use the binding-based export from
@hot-updater/cloudflare/worker.
Limitations
- S3-compatible credentials are required for the root export's runtime profile.
- Legacy configs with
cloudflareApiTokenuse Wrangler and support only the node profile.
Protocol
r2://
This prefix is stored in the storageUri field in the database.