Skip to content
GitHubXDiscord

Redwood

Deploy a RedwoodJS application to Cloudflare Pages with automatically configured defaults. This resource handles the deployment of RedwoodJS applications with optimized settings for Cloudflare Workers.

Deploy a basic RedwoodJS application with default settings:

import { Redwood } from "alchemy/cloudflare";
const redwoodApp = await Redwood("my-redwood-app");

Add a D1 database binding to your RedwoodJS application:

import { Redwood, D1Database } from "alchemy/cloudflare";
const database = await D1Database("redwood-db");
const redwoodApp = await Redwood("redwood-with-db", {
bindings: {
DB: database,
},
});

Deploy with custom build command and environment variables:

import { Redwood } from "alchemy/cloudflare";
const redwoodApp = await Redwood("custom-redwood", {
command: "bun run test && RWSDK_DEPLOY=1 bun run build:production",
bindings: {
API_KEY: alchemy.secret("api-key-secret"),
},
vars: {
NODE_ENV: "production",
APP_ENV: "staging",
},
});

Bind a RedwoodJS application to a Worker:

import { Worker, Redwood } from "alchemy/cloudflare";
const redwoodApp = await Redwood("my-redwood-app", {
name: "redwood-worker",
command: "bun run build",
});
await Worker("my-worker", {
name: "my-worker",
script: "console.log('Hello from worker')",
bindings: {
REDWOOD: redwoodApp,
},
});

The transform hook allows you to customize the wrangler.json configuration. For example, adding a custom environment variable:

await Redwood("my-app", {
transform: {
wrangler: (spec) => ({
...spec,
vars: {
...spec.vars,
CUSTOM_VAR: "value",
},
}),
},
});