Documentation

R2 (Object Storage)

in-progress

R2 hosts your /public assets and any large files your app reads at runtime. NextDeploy uploads assets on every deploy, optionally with a public bucket policy for direct CDN serving.

Source reference: cli/internal/serverless/cloudflare_r2.go (and related), shared/nextcompile/ (asset detection)


What R2 is for in NextDeploy

TODO static /public assets, build artifacts (e.g. compiled images), user uploads. Free egress is the killer feature vs S3.

Asset upload flow

TODO during nextdeploy deploy — diff against existing keys, upload new + changed, prune (optional) deleted. Idempotent.

Public bucket vs binding-only

TODO public bucket lets the worker fetch by URL — simpler, but not all routes want that. Binding-only is more secure.

Custom domain on R2

TODO if exposing assets directly, point a CF domain at the bucket. NextDeploy can manage this via DNS bindings.

Cache headers

TODO what NextDeploy sets by default for /public, immutable hashed assets vs HTML, override per pattern.

Reading from R2 in your app

TODO code example — env.MY_BUCKET.get("path/to/file"), range requests, multipart uploads for large files.

Lifecycle rules

TODO when to use, how to declare in nextdeploy.yml, common patterns (delete old uploads after N days).

Limits & cost

TODO R2 storage cost, class A operations (writes), class B (reads), free egress, free tier numbers.

Related