Skip to main content

Nuxt on Cloudflare Example

This example demonstrates deploying a Nuxt application to Cloudflare with R2 Bucket storage and Pipeline for analytics.

Features

  • Nuxt: Vue.js meta-framework with SSR
  • R2 Bucket: Object storage for data
  • Pipeline: Analytics and data pipeline to R2
  • Type Safety: Full TypeScript support
  • Edge Rendering: Server-side rendering at the edge

Project Setup

Key Features Explained

R2 Bucket

Create an R2 bucket for object storage:

Pipeline for Analytics

Pipeline writes analytics data to R2:

Bindings in Nuxt

Both R2 and Pipeline are available in server routes:

Server-Side Access

Access bindings in Nuxt server routes:

Pipeline Batching

Pipeline automatically batches writes based on:
  • maxMb: Maximum batch size in MB (10)
  • maxSeconds: Maximum time before flush (5 seconds)
  • maxRows: Maximum number of rows (100)

Analytics Query Example

Query analytics data from R2:

Use Cases

  • File Storage: Upload and serve files from R2
  • Analytics: Track events with Pipeline
  • Data Lakes: Store structured data in R2
  • Logging: Batch logs to R2 via Pipeline

Source Code

View the complete source code: examples/cloudflare-nuxt-pipeline