Deploying with Alchemy
Deploy Better-T-Stack projects to Cloudflare or Prisma and manage hosted databases in the same typed stack
Overview
Alchemy is the infrastructure-as-code layer generated when you choose Cloudflare or Prisma as a deployment target. The CLI writes a packages/infra workspace containing:
- one
alchemy.run.tsfor applications, managed databases, and migrations - exact compatible Alchemy and Effect versions
- root
dev,deploy, anddestroycommands
Supported deployment shapes
Cloudflare supports separate Hono and Nitro servers on the Workers runtime and supported web frameworks. Full-stack backend: self projects deploy as one web application.
Prisma supports:
- web: TanStack Router, Next.js, Nuxt, Astro, React Router, TanStack Start, SvelteKit, and Solid
- server: Hono, Express, Fastify, Elysia, and Nitro on Bun or Node
- mixed stacks, such as Cloudflare web + Prisma server or Prisma web + Cloudflare server
The CLI rejects unsupported framework/runtime combinations before writing files.
With Next.js on Cloudflare, Prisma ORM supports Neon and Prisma Postgres. Generic PostgreSQL connections, including Supabase and PlanetScale Postgres, are not supported for that combination.
Nitro servers use native provider output. Prisma Compute deploys .output/server/index.mjs from Nitro's command build. Cloudflare builds the official cloudflare_module preset, deploys the same prebuilt ESM entrypoint without rebundling it, and uploads .output/public as Worker assets.
Alchemy's automatic framework builds handle Next.js, Nuxt, Astro, and TanStack Start. The generated
stack supplies explicit production artifacts for the remaining frameworks: Solid's Nitro
server, React Router's documented custom Express server, and SvelteKit's official adapter-node
server. TanStack Router is rejected for Prisma deployment because it emits static SPA assets while
Prisma.Compute requires an executable server artifact; the generator does not synthesize a static
file server or use Vite's development-oriented preview command.
Cloudflare web deployment uses Alchemy's released framework resources where they match the
generated stable framework: Website.Nuxt for Nuxt, Website.Astro for Astro, and Website.Vite
for React Router, TanStack Router, TanStack Start, and Solid. Next.js and stable SvelteKit keep
their qualified StaticSite paths until the released first-class resources accept the latest
OpenNext and stable SvelteKit versions.
Prisma with a generic node-postgres connection, including PlanetScale Postgres and Supabase, is
temporarily unavailable with Next.js on Cloudflare until OpenNext preserves pg-cloudflare's
workerd runtime files.
Next.js with Neon or Prisma Postgres remains supported on Cloudflare. The same PlanetScale Postgres Prisma setup remains supported with the other Cloudflare SSR frontends or with Prisma, Docker, or Vercel deployment.
# Full-stack Solid on Prisma with PlanetScale MySQL
bunx @wundero/bts@latest my-app \
--frontend solid \
--backend self \
--database mysql \
--orm prisma \
--db-setup planetscale \
--web-deploy prisma
# Next.js on Cloudflare and a Hono/Bun server on Prisma
bunx @wundero/bts@latest my-app \
--frontend next \
--backend hono \
--runtime bun \
--database postgres \
--orm prisma \
--db-setup neon \
--web-deploy cloudflare \
--server-deploy prismaProvider login
Install dependencies, then let Alchemy configure every provider used by the stack:
bun install
cd packages/infra
bunx alchemy profile editAlchemy stores provider profiles under ~/.alchemy. For Alchemy-managed databases, it creates the database and supplies the connection details to your application.
Managed databases
Alchemy can create and manage Neon, PlanetScale, and Prisma Postgres databases when the backend deploys to Cloudflare or Prisma:
backend: self: the web deployment owns the database- separate backend: the server deployment owns the database
If the backend deploys elsewhere, configure its database separately.
| Setup | What Alchemy creates |
|---|---|
| Neon | A project and database connection |
| PlanetScale Postgres | A database and application credentials |
| PlanetScale MySQL | A database and application credentials |
| Prisma Postgres | A project, database, and connection |
| Cloudflare D1 | A database bound to your Worker |
PlanetScale can charge for PS_DEV databases. Review clusterSize in
packages/infra/alchemy.run.ts before deploying.
Migration workflow
After changing your database schema, generate a migration:
# Drizzle: generate SQL from the current schema
bun run db:generate
# Prisma: create a migration, then regenerate the client
bun run db:migrate
bun run db:generateReview and commit the generated migration files. Alchemy applies migrations for managed databases during deployment.
Develop and deploy
Run these commands from the project root:
bun run dev
bun run deploy
bun run destroydevstarts local development.deploybuilds and deploys your applications and managed resources.destroyremoves the resources in the selected stage, including managed databases.
Deployments are staged. For an explicit production stage:
cd packages/infra
bunx alchemy deploy --stage productionUse the same stage when destroying it:
bunx alchemy destroy --stage productionEnvironment variables
Set infrastructure configuration in packages/infra/.env and application configuration in the relevant app's .env file. Alchemy supplies managed database connections and deployed application URLs automatically.
Keep secrets out of version control. Run bun run deploy after changing deployment configuration.
Customize your infrastructure
Edit packages/infra/alchemy.run.ts to change regions, database sizes, or add resources. See the Alchemy documentation for the available resources and options.