
By Mehdi Zare
Store media in Cloudflare R2 with automatic edge image resizing and on-the-fly WebP/AVIF optimization.
released March 3, 2026
npm install strapi-plugin-cloudflare-r2-assets
Strapi 5 upload provider and plugin that stores media assets in Cloudflare R2. Drop it into any Strapi 5 project for S3-compatible object storage backed by Cloudflare R2. Strapi handles all image variants natively.
npm install strapi-plugin-cloudflare-r2-assetsRequired:
| Variable | Description |
|---|---|
CF_R2_ACCOUNT_ID | Cloudflare account ID |
CF_R2_BUCKET | R2 bucket name |
CF_R2_ACCESS_KEY_ID | R2 API access key ID |
CF_R2_SECRET_ACCESS_KEY | R2 API secret access key |
CF_PUBLIC_BASE_URL | Public URL for asset delivery (e.g. https://media.example.com) |
Optional:
| Variable | Default | Description |
|---|---|---|
CF_R2_ENDPOINT | https://<accountId>.r2.cloudflarestorage.com | Custom R2 endpoint |
CF_R2_BASE_PATH | uploads | Object key prefix |
CF_R2_CACHE_CONTROL | — | Cache-Control header for uploaded objects |
CF_R2_REQUEST_TIMEOUT | 30000 | Request timeout in milliseconds |
CF_R2_ENV_PREFIX | — | Prefix for env keys (e.g. APP_ reads APP_CF_R2_ACCOUNT_ID) |
Create or update config/plugins.ts:
export default () => ({
// Upload provider — stores files in R2 and serves Cloudflare edge URLs
upload: {
config: {
provider: 'strapi-plugin-cloudflare-r2-assets',
providerOptions: {},
},
},
// Admin diagnostics page (Settings > Cloudflare R2 Assets)
'cloudflare-r2-assets': {
enabled: true,
},
});All settings are resolved from environment variables by default. You can optionally override defaults in providerOptions:
providerOptions: {
basePath: 'uploads', // default: 'uploads'
},Set CF_R2_ENV_PREFIX to resolve prefixed values. For example, with CF_R2_ENV_PREFIX=CMS_, the plugin resolves CMS_CF_R2_ACCOUNT_ID, CMS_CF_R2_BUCKET, etc., and then falls back to unprefixed keys when needed.
After installation, navigate to Settings > Cloudflare R2 Assets in the Strapi admin panel.
The page is read-only and shows:

Access requires the plugin read permission: plugin::cloudflare-r2-assets.read
CF_PUBLIC_BASE_URL and CF_R2_ENDPOINT must be valid http(s) URLsContributions are welcome! See AGENTS.md for development setup, commands, release workflow, and contribution guidelines.
MIT
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
