sellStorage & Databases
inventory_2

R2

Store any file in the cloud and pay nothing to read it back out.

$0Egress fees
$0.015Per GB-month stored
10 GBFree storage / month
S3API compatible
lightbulb

What is R2?

R2 is object storage (object storage = a service for keeping large files like images, videos, backups, and datasets). You upload files, get them back by name, and never worry about running a disk yourself.

Each file you store is called an object, and objects live inside a bucket (a bucket = a named folder-like container that holds your objects). R2 also speaks the same API as Amazon S3, the most popular object storage in the world, so existing S3 tools and code work with very few changes.

warehouse

Think of it like…

A giant self-storage warehouse. You rent space by how much you store, but unlike other warehouses, taking your boxes out to look at them is completely free — that is the famous 'zero egress' part.

help

Why use R2?

Traditional cloud storage charges an 'egress fee' (egress = the cost of moving data OUT of the cloud to your users). For a popular site or app, that surprise bill can be larger than the storage itself. R2 removes it entirely.

money_off

No egress fees

Reading your files out to the internet costs $0, no matter how much traffic you serve.

cable

Works with S3 tools

Point existing S3 SDKs, CLIs, and apps at R2 with almost no code changes.

public

Global by default

Files are served from Cloudflare's worldwide network, close to your users.

bolt

Pairs with Workers

Read and write objects directly from Workers code via a simple binding.

target

When should you use it?

image

User uploads & media

Profile photos, product images, PDFs, and video files for a website or app.

backup

Backups & archives

Database dumps and logs you rarely change but want to keep safely and cheaply.

movie

High-traffic downloads

Software releases, datasets, or podcast episodes downloaded by many people — where egress fees would normally hurt.

analytics

Data lakes

Store raw analytics and big-data files for later processing (this is where Pipelines feeds data in).

rocket_launch

How do you start?

Wrangler is Cloudflare's command-line tool (a CLI = a program you type commands into in your terminal). The steps below create a bucket, connect it to a Worker, and read/write an object.

  1. Install Wrangler & log in

    Install the tool, then log in to your Cloudflare account in the browser window it opens.

    bash
    npm install -g wrangler
    wrangler login
  2. Create a bucket

    Bucket names use lowercase letters, numbers, and hyphens, 3-63 characters long.

    bash
    wrangler r2 bucket create my-app-files
    wrangler r2 bucket list
  3. Bind the bucket to your Worker

    A binding gives your code a variable (here MY_BUCKET) to reach the bucket. Add this to wrangler.jsonc.

    json
    {
      "r2_buckets": [
        {
          "binding": "MY_BUCKET",
          "bucket_name": "my-app-files"
        }
      ]
    }
  4. Read & write objects from code

    A PUT request stores the body as an object; any other request reads it back by name.

    js
    export default {
      async fetch(request, env) {
        const key = new URL(request.url).pathname.slice(1);
    
        if (request.method === "PUT") {
          await env.MY_BUCKET.put(key, request.body);
          return new Response(`Uploaded ${key}!`);
        }
    
        const object = await env.MY_BUCKET.get(key);
        if (object === null) {
          return new Response("Object Not Found", { status: 404 });
        }
        return new Response(object.body);
      },
    };
  5. Deploy

    Publish your Worker to Cloudflare's global network.

    bash
    wrangler deploy
school

Key concepts

description

Object

A single stored file plus its metadata, found by a unique key (its name/path).

folder

Bucket

A named container that holds many objects, like a top-level folder.

swap_vert

Class A vs Class B

Class A = writes/lists ($4.50/million); Class B = reads ($0.36/million). Egress is still free.

vpn_key

S3 compatibility

R2 accepts the same requests as Amazon S3, so S3 SDKs and migration tools just work.

tips_and_updates

Tips & pricing

savings

The free tier is generous

Every month you get 10 GB of storage, 1 million Class A operations, and 10 million Class B operations free — plenty for learning and small projects.

  • Storage is billed at $0.015 per GB-month; you only pay for what you store.
  • Egress (serving files to the internet) is always $0 — this is R2's headline feature.
  • Use clear key prefixes like uploads/2026/photo.jpg to organize objects like folders.
  • Connect a custom domain to a bucket to serve files publicly with no Worker required.