Overview

Cloudflare R2 is a distributed object storage service that provides S3-compatible API access, allowing developers to store large amounts of unstructured data at the edge. Launched by Cloudflare, a company founded in 2009, R2 differentiates itself by eliminating egress fees, which typically constitute a significant cost for data retrieval in cloud storage models Cloudflare R2 product page. This design choice aims to reduce the financial barriers associated with data transfer, particularly for applications requiring frequent data access or global distribution.

R2 is positioned for use cases that benefit from data locality and reduced latency. By distributing data across Cloudflare's global network, R2 aims to serve content closer to end-users, potentially improving application performance for static assets, media files, and other web content Cloudflare R2 developer documentation. Its compatibility with the S3 API means that developers can often migrate existing applications or integrate new ones using familiar tools and SDKs, such as the AWS SDK for JavaScript v3 or Python (Boto3) Cloudflare R2 API reference. This compatibility can lower the learning curve and accelerate adoption for teams already familiar with AWS S3.

The service integrates with Cloudflare Workers, allowing for serverless functions to process and manipulate data stored in R2 directly at the edge. This can enable dynamic content generation, image resizing, or custom access control logic without needing traditional server infrastructure. R2's pricing model is based on stored data volume and operations (Class A for writes/updates and Class B for reads), with no charges for data egress. This structure is intended to provide predictable costs and flexibility for applications that experience high read traffic or require frequent data transfers across different regions.

Cloudflare R2 targets developers and technical buyers seeking cost-effective and performant storage solutions for applications that benefit from a global presence. This includes static site hosting, serving user-generated content, storing backups, and delivering large media files. Its compliance certifications, including SOC 2 Type II, GDPR, and PCI DSS Level 1, address regulatory requirements for various industries Cloudflare R2 product page, making it suitable for sensitive data storage when properly configured.

Key features

  • S3-Compatible API: Utilizes an API that is compatible with Amazon S3, enabling the use of existing S3 tools, libraries, and SDKs such as the AWS SDK for Go v2 or Java v2 Cloudflare R2 API reference.
  • No Egress Fees: Eliminates charges for data transfer out of the R2 storage, a departure from traditional cloud storage models that often include egress fees Cloudflare R2 pricing page.
  • Global Distribution: Stores data across Cloudflare's global network, aiming to provide low-latency access by serving content from locations geographically closer to end-users.
  • Integration with Cloudflare Workers: Allows serverless functions running on Cloudflare Workers to interact directly with R2 buckets, enabling edge-based data processing and dynamic content delivery Cloudflare R2 Workers integration.
  • Automatic Replication: R2 automatically replicates data across multiple locations for durability and availability, aligning with current cloud storage best practices Cloudflare R2 data consistency.
  • Cost-Effective Pricing: Features a pricing model focused on storage volume and operation counts, without additional charges for data retrieval or geographic egress Cloudflare R2 pricing page. This contrasts with services like Amazon S3's data transfer out charges, which can accumulate based on volume.
  • Compliance Certifications: Supports various compliance standards, including SOC 2 Type II, GDPR, ISO 27001, ISO 27701, and PCI DSS Level 1, addressing enterprise and regulatory requirements Cloudflare R2 product page.

Pricing

Cloudflare R2 offers a free tier and a pay-as-you-go model for usage beyond the free limits. As of June 2026, the pricing structure is detailed below Cloudflare R2 pricing page:

Resource Free Tier Paid Tier (per unit)
Storage 10 GB-months $0.015 / GB-month
Class A Operations (writes/updates) 1,000,000 operations $4.50 / million operations
Class B Operations (reads) 10,000,000 operations $0.36 / million operations
Egress Fees $0 $0

The free tier provides a starting point for development and small-scale applications, covering a significant amount of storage and operations. Once these limits are exceeded, billing automatically moves to the paid tier rates. The absence of egress fees is a core component of R2's pricing strategy, aiming to provide cost predictability, especially for applications with high data transfer requirements.

Common integrations

Cloudflare R2's S3-compatible API facilitates integration with a range of tools and services. Key integration points include:

  • Cloudflare Workers: Serverless functions for processing and transforming data directly at the edge Integrate R2 with Cloudflare Workers.
  • AWS SDKs: Utilize standard AWS SDKs across various languages like JavaScript, Python (Boto3), Go, Java, .NET, PHP, and Ruby for interacting with R2 buckets Cloudflare R2 API reference for SDKs.
  • Popular S3 Clients: Tools such as s3cmd, rclone, and various S3-compatible file browsers can connect to R2 for object management.
  • Content Management Systems (CMS): Integration with CMS platforms that support S3 for media storage, such as WordPress with an S3 plugin.
  • Static Site Generators: Deploying static sites generated by tools like Hugo, Jekyll, or Next.js directly to R2 for hosting.

Alternatives

For object storage needs, several alternatives offer similar or complementary functionalities:

  • Amazon S3: A widely adopted object storage service offering high scalability, availability, and a broad ecosystem of integrations.
  • Google Cloud Storage: Google's scalable and durable object storage, integrated with the Google Cloud ecosystem, offering various storage classes.
  • Azure Blob Storage: Microsoft Azure's object storage solution for unstructured data, with different access tiers and strong integration with Azure services.
  • DigitalOcean Spaces: An S3-compatible object storage service known for its developer-friendly interface and predictable pricing, often favored by smaller teams and startups.
  • Linode Object Storage: Provides S3-compatible object storage with transparent pricing, suitable for developers building in the Linode ecosystem.

Getting started

To begin using Cloudflare R2, you typically need to create an R2 bucket and then configure your application to interact with it using an S3-compatible client or SDK. Here's an example using the AWS SDK for JavaScript v3 to upload an object to an R2 bucket. This assumes you have already configured your Cloudflare R2 API credentials as environment variables or passed them directly.

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

const R2_ACCOUNT_ID = process.env.R2_ACCOUNT_ID;
const R2_ACCESS_KEY_ID = process.env.R2_ACCESS_KEY_ID;
const R2_SECRET_ACCESS_KEY = process.env.R2_SECRET_ACCESS_KEY;

// Initialize S3Client with R2 endpoint and credentials
const S3 = new S3Client({
  region: "auto",
  endpoint: `https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com`,
  credentials: {
    accessKeyId: R2_ACCESS_KEY_ID,
    secretAccessKey: R2_SECRET_ACCESS_KEY,
  },
});

const uploadFileToR2 = async (bucketName, key, body, contentType) => {
  try {
    const command = new PutObjectCommand({
      Bucket: bucketName,
      Key: key,
      Body: body,
      ContentType: contentType,
    });

    const response = await S3.send(command);
    console.log(`Successfully uploaded ${key} to ${bucketName}.`, response);
    return response;
  } catch (error) {
    console.error(`Error uploading file to R2:`, error);
    throw error;
  }
};

// Example usage:
// const myBucket = "my-r2-bucket";
// const myKey = "hello-world.txt";
// const fileContent = "Hello from Cloudflare R2!";
// const fileContentType = "text/plain";

// uploadFileToR2(myBucket, myKey, fileContent, fileContentType)
//   .then(() => console.log("Upload process completed."))
//   .catch((err) => console.error("Upload failed:", err));

This JavaScript example demonstrates how to configure the AWS SDK to connect to your R2 endpoint and perform a basic object upload. The region: "auto" setting is common for R2, and the endpoint URL is constructed using your Cloudflare R2 Account ID. For more detailed examples and advanced operations, consult the Cloudflare R2 API Reference.