xiaohongshu
xiaohongshu
alchemy-cloudflare
Alchemy IaC patterns for deploying TanStack Start apps to Cloudflare Workers with D1 databases. Use when setting up new TanStack Start projects, configuring Alchemy deployments, working with D1/Drizzle migrations, local development with Cloudflare bindings, or deploying to custom domains.
Full skill instructions
TypeScript-first Infrastructure as Code for deploying TanStack Start applications to Cloudflare Workers.
typeof worker.Env provides types without codegenalchemy.secret() encrypts values with ALCHEMY_PASSWORDpnpm add alchemy @cloudflare/workers-types
import alchemy from "alchemy"
import { D1Database, TanStackStart } from "alchemy/cloudflare"
const app = await alchemy("my-app", {
stage: process.env.STAGE ?? "dev",
phase: process.argv.includes("--destroy") ? "destroy" : "up",
})
const db = await D1Database("my-d1", {
migrationsDir: "./drizzle", // Auto-applies Drizzle migrations
})
const worker = await TanStackStart("my-worker", {
d1Databases: { DB: db },
domains: ["my-app.com"], // Custom domain
})
export type Env = typeof worker.Env
await app.finalize()
CRITICAL: Alchemy plugin must be FIRST in plugins array.
// app.config.ts
import { defineConfig } from "@tanstack/react-start/config"
import viteTsConfigPaths from "vite-tsconfig-paths"
import { alchemy } from "alchemy/cloudflare/tanstack-start"
export default defineConfig({
vite: {
plugins: [
alchemy(), // MUST be first
viteTsConfigPaths({ root: "./" }),
],
build: {
target: "esnext",
rollupOptions: {
external: ["node:async_hooks", "cloudflare:workers"],
},
},
},
})
# Set encryption password (once)
export ALCHEMY_PASSWORD="your-secure-password"
# Deploy
bun alchemy.run.ts
# Deploy to specific stage
STAGE=prod bun alchemy.run.ts
# Destroy resources
bun alchemy.run.ts --destroy
# Run dev server with Cloudflare emulation
pnpm alchemy dev
What this provides:
.alchemy/{app}/{stage}/)Env types as productionOnly required env var:
ALCHEMY_PASSWORD=your-password
src/db/schema.tspnpm drizzle-kit generatebun alchemy.run.ts (auto-applies migrations)// In server functions or loaders
import { getCloudflareContext } from "@opennextjs/cloudflare"
export async function loader() {
const { env } = await getCloudflareContext()
const db = drizzle(env.DB)
// Use db...
}
const stage = process.env.STAGE ?? "dev"
const app = await alchemy("my-app", { stage })
// Conditional resources
const domains = stage === "prod"
? ["app.com", "www.app.com"]
: [`${stage}.app.com`]
await TanStackStart("worker", { domains })
// In alchemy.run.ts
const worker = await TanStackStart("worker", {
vars: {
PUBLIC_API_URL: "https://api.example.com",
},
secretTextBindings: {
AUTH_SECRET: alchemy.secret(process.env.AUTH_SECRET!),
STRIPE_KEY: alchemy.secret(process.env.STRIPE_KEY!),
},
})
import { KVNamespace, TanStackStart } from "alchemy/cloudflare"
const sessions = await KVNamespace("sessions")
await TanStackStart("worker", {
kvNamespaces: { SESSIONS: sessions },
})
Add to vite config:
rollupOptions: {
external: ["node:async_hooks", "cloudflare:workers"],
}
Server functions must be in src/server-fns/ files, not inline in route files. Routes can only import and call server functions.
Check .alchemy/{app}/{stage}/ directory exists. Ensure ALCHEMY_PASSWORD is set.
Verify migrationsDir points to correct directory (where .sql files are).
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience