Integrate Cloudflare R2 object storage with Convex to store and serve files with high performance and low egress costs.
npm install @convex-dev/r2A R2 component for Convex.
The @convex-dev/r2 component provides direct integration between Convex functions and Cloudflare R2. You can upload files from mutations or actions using the R2 client, which handles authentication and multipart uploads automatically.
This component connects Convex to Cloudflare R2, giving you global file storage with automatic CDN distribution. Files stored in R2 are served through Cloudflare's edge network for faster delivery worldwide.
Cloudflare R2 offers competitive storage pricing with zero egress fees. The @convex-dev/r2 component lets you store user uploads, images, and documents in R2 while keeping your Convex database focused on structured data.
Yes, the @convex-dev/r2 component supports streaming uploads and downloads for large files. This prevents memory issues when handling large files in your Convex functions and provides better performance for file operations.
The @convex-dev/r2 component uses your Cloudflare R2 API credentials stored as Convex environment variables. You provide your account ID, access key, and secret key, and the component handles authentication automatically.
Yes, @convex-dev/r2 supports custom domains configured in your Cloudflare R2 bucket settings. You can serve files through your own domain while still managing uploads and storage operations through the component.
The @convex-dev/r2 component can store any file type that Cloudflare R2 supports, including images, videos, documents, and binary files. There are no restrictions imposed by the component itself, only R2's standard limits.