Skip to main content

cloudflareDevProxy

Provides Cloudflare Workers bindings to your loaders and actions during local development.

Import

Usage

The cloudflareDevProxy plugin must be placed before the reactRouter plugin.

Options

function
Custom function to provide load context to your loaders and actions.
Example:
boolean | { path: string }
Enables persistent storage for Cloudflare bindings (KV, DO, R2, D1).Default: true (persists to .wrangler/state/v3)
string
Path to wrangler.toml configuration file.Default: "./wrangler.toml"
boolean
Use wrangler.json instead of wrangler.toml.Default: false

Configuration

TypeScript Types

Define your Cloudflare environment types:

wrangler.toml

Configure your Cloudflare bindings:

Common Patterns

Accessing Bindings in Loaders

Accessing Bindings in Actions

Custom Load Context

Extend the context with custom utilities:

Durable Objects

Service Bindings

Production Deployment

In production, Cloudflare provides actual bindings. The dev proxy is only for local development.

Build Configuration

Deploy to Cloudflare Pages

Troubleshooting

Bindings Not Available

Ensure:
  1. Plugin is before reactRouter()
  2. wrangler.toml is properly configured
  3. Types are properly declared

D1 Database Issues

Create local D1 database:

KV Persistence

Data persists to .wrangler/state/v3 by default. Clear with: