R2 (2)
Last updated Oct 1, 2026 R2 sinks write processed data from pipelines as raw files to R2 object storage. They currently support writing to JSON and Parquet formats.
To create an R2 sink, run the basin pipelines sinks create command and specify the sink type and target bucket:
npmyarnpnpm
npx wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket
yarn wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket
pnpm wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket
Format options
R2 sinks support two output formats:
JSON format
Write data as newline-delimited JSON files. JSON sinks support two compression modes: uncompressed (default) and gzip:
--format json --compression gzip
Parquet format
Write data as Parquet files for better query performance and compression:
--format parquet --compression zstd
Compression options for Parquet:
zstd(default) - Best compression ratiosnappy- Fastest compressiongzip- Good compression, widely supportedlz4- Fast compression with reasonable ratiouncompressed- No compression
Row group size: Row groups ↗︎ are sets of rows in a Parquet file that are stored together, affecting memory usage and query performance. Configure the target row group size in MB:
--target-row-group-size 256
File organization
Files are written with UUID names within the partitioned directory structure. For example, with path analytics and default partitioning:
analytics/year=2025/month=09/day=18/002507a5-d449-48e8-a484-b1bea916102f.parquet
Path
Set a base directory in your bucket where files will be written:
--path analytics/events
Partitioning
R2 sinks automatically partition files by time using a configurable pattern. The default pattern is year=%Y/month=%m/day=%d (Hive-style partitioning).
--partitioning "year=%Y/month=%m/day=%d/hour=%H"
For available format specifiers, refer to strftime documentation ↗︎.
Batching and rolling policy
Control when files are written to R2. Configure based on your needs:
- Lower values: More frequent writes, smaller files, lower latency
- Higher values: Less frequent writes, larger files, better query performance
Roll interval
Set how often files are written (default: 300 seconds, minimum: 10 seconds):
--roll-interval 10 # Write files every 10 seconds
Roll size
Set maximum file size in MB before creating a new file:
--roll-size 100 # Create new file after 100MB
Authentication
R2 sinks require an API credentials (Access Key ID and Secret Access Key) with Object Read & Write permissions to write data to your bucket.
npmyarnpnpm
npx wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket --access-key-id YOUR_ACCESS_KEY_ID --secret-access-key YOUR_SECRET_ACCESS_KEY
yarn wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket --access-key-id YOUR_ACCESS_KEY_ID --secret-access-key YOUR_SECRET_ACCESS_KEY
pnpm wrangler basin pipelines sinks create my-sink --type r2 --bucket my-bucket --access-key-id YOUR_ACCESS_KEY_ID --secret-access-key YOUR_SECRET_ACCESS_KEY
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/basin-pipelines/sinks/available-sinks/r2/#page","headline":"R2","description":"Write data as JSON or Parquet files to R2 object storage","url":"https://developers.cloudflare.com/basin-pipelines/sinks/available-sinks/r2/","inLanguage":"en","image":"https://developers.cloudflare.com/basin-pipelines/sinks/available-sinks/r2/og.png?v=52e9b14a88b84d69","dateModified":"2026-10-01","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Write data as Apache Iceberg tables to Basin Catalog title: Basin Catalog image: https://developers.cloudflare.com/basin-pipelines/sinks/available-sinks/r2-data-catalog/og.png?v=9d9855a6c7edd678
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/basin-pipelines/llms.txt
Use this file to discover all available pages before exploring further.
Docs