How do you configure an S3-compatible client for Cloudflare R2?
Set the R2 endpoint, bucket, and scoped credentials before testing a small object operation.
How do you configure an S3-compatible client for Cloudflare R2?
R2 supports an S3-compatible API, but the client must target the correct account endpoint and use the corresponding credentials.
Configure the storage client
Use the R2 account’s S3 API endpoint, the intended bucket, and an access key pair with suitable bucket permissions. Follow Cloudflare’s current SDK example for region and client options rather than copying an unrelated AWS configuration unchanged. Keep secrets in server or worker configuration.
Verify the exact operations
Upload a tiny development object, read it back, and remove the test object when appropriate. Confirm its key and content type. A successful credential check does not prove the application can perform every required operation. Separate authentication failures from an incorrect endpoint, bucket name, or object key. Document the configuration names needed by both the API server and media worker without recording secret values.
Further reading: R2 S3 setup.
Configure the R2 account endpoint; do not assume the default endpoint targets R2.
No. Use trusted server or worker configuration and scoped temporary access for browsers when needed.
A small upload and authorized read against the exact bucket and key pattern the application uses.
Related learning resources
Ready to master AI completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master AI
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

