The alchemy.run.ts file defines your infrastructure using Alchemy (an Infrastructure-as-Code library). You can define D1 databases, web frontends (using framework-specific resources), and server workers.
Supported Framework Resources:
Nextjs: Uses OpenNext adapterNuxt: Uses Nitro Cloudflare presetSvelteKit: Uses Alchemy SvelteKit adapterTanStackStart: Full SSR supportReactRouter: Uses React Router Cloudflare adapterVite: Used for static sites (TanStack Router, SolidJS)
Example Configuration:
// packages/infra/alchemy.run.ts
import alchemy from "alchemy";
import { TanStackStart } from "alchemy/cloudflare";
import { Worker } from "alchemy/cloudflare";
import { D1Database } from "alchemy/cloudflare";
import { config } from "dotenv";
config({ path: "./.env" });
config({ path: "../../apps/web/.env" });
config({ path: "../../apps/server/.env" });
const app = await alchemy("my-app");
const db = await D1Database("database", {
migrationsDir: "../../packages/db/prisma/migrations",
});
export const web = await TanStackStart("web", {
cwd: "../../apps/web",
bindings: {
VITE_SERVER_URL: alchemy.env.VITE_SERVER_URL!,
},
});
export const server = await Worker("server", {
cwd: "../../apps/server",
entrypoint: "src/index.ts",
compatibility: "node",
bindings: {
DB: db,
CORS_ORIGIN: alchemy.env.CORS_ORIGIN!,
BETTER_AUTH_SECRET: alchemy.secret.env.BETTER_AUTH_SECRET!,
BETTER_AUTH_URL: alchemy.env.BETTER_AUTH_URL!,
},
dev: {
port: 3000,
},
});
await app.finalize();