---
title: "Image Hosting with Cloudflare R2"
description: "A guide to building an image hosting platform with Cloudflare R2"
---

> Documentation Index
> Fetch the complete documentation index at: https://luozhouyang.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Hosting with Cloudflare R2

Cloudflare R2 is a cloud storage service built on the Amazon S3 API. It lets you store any number of objects and access them over an HTTP API. With Cloudflare R2 we can build an image hosting service for storing and sharing images.

## What makes Cloudflare R2 worth a look

- [x] Store any number of objects
- [x] S3 API compatible
- [x] No egress charges
- [x] 10 GB of free storage

## Steps

1. Create a Cloudflare account
2. Create an R2 bucket
3. Configure access permissions
4. Upload images
5. Get the image URL

## Pricing plans

| Feature | Free plan | Paid plan |
| --- | --- | --- |
| Storage | 10 GB | Unlimited |
| Egress | Free | Free |
| Requests | 100,000 per day | Unlimited |

## Reference code

```typescript
const s3 = new S3Client({
  region: 'auto',
  endpoint: 'https://r2.cloudflare.com',
  credentials: {
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
  },
})
```

Source: https://luozhouyang.com/cloudflare/r2-image-hosting/index.mdx
