Skip to main content
Deploy RedwoodJS applications to Cloudflare Workers with optimized build settings.

Installation

Install the required dependencies:

Configuration

Configuration Options

Properties

  • bindings: Cloudflare bindings (KV, R2, D1, etc.)
  • build: Build command and environment
    • Default command: rm -rf ./node_modules/.vite && vite build
    • Default env: { RWSDK_DEPLOY: "1" }
  • entrypoint: Worker entrypoint path
    • Default: dist/worker/index.js
  • compatibilityFlags: Cloudflare compatibility flags
    • Default: ["nodejs_compat"]
  • compatibilityDate: Cloudflare compatibility date
    • Default: 2025-08-21
  • wrangler.main: Path to worker source file
    • Default: src/worker.tsx

Build Process

The Redwood resource performs these build steps:
  1. Clears Vite cache (node_modules/.vite)
  2. Runs Vite build with RWSDK_DEPLOY=1
  3. Bundles worker code
  4. Outputs to dist/worker/

Custom Build Command

Accessing Bindings

Access Cloudflare bindings in your RedwoodJS application:

GraphQL Resolvers

Services

Database Integration

Use D1 Database with Prisma:
Configure Prisma for D1:

Node.js Compatibility

RedwoodJS automatically enables:
  • nodejs_compat compatibility flag
  • Node.js built-in modules
  • Full RedwoodJS feature set
  • Prisma support

Local Development

Start the RedwoodJS dev server:
The dev server provides:
  • Hot module replacement
  • GraphQL Playground
  • Storybook integration
  • Database migrations

Vite Cache Management

The default build command clears Vite cache to prevent stale builds:
Skip cache clearing if needed:

TypeScript Configuration

Define types for Cloudflare bindings:

Deployment Best Practices

  • Keep dist/ directory in .gitignore
  • Use D1 Database for data persistence
  • Configure DATABASE_URL for Prisma
  • Test migrations locally before deploying
  • Clear Vite cache on build failures