Getting Started
Alchemy is a simple TypeScript script that you run to deploy infrastructure. All you need is a Node.js runtime and a Cloudflare account to get started.
-
Create your project
Start by creating a new project and installing Alchemy.
Terminal window mkdir my-alchemy-appcd my-alchemy-appTerminal window bun init -ybun add alchemyTerminal window npm init -ynpm install alchemyTerminal window pnpm initpnpm add alchemyTerminal window yarn init -yyarn add alchemy -
Login to Cloudflare
Authenticate with your Cloudflare account.
Terminal window bun alchemy loginTerminal window npx alchemy loginTerminal window pnpm alchemy loginTerminal window yarn alchemy login -
Create your infrastructure
Create
alchemy.run.ts
with a simple Worker:import alchemy from "alchemy";import { Worker } from "alchemy/cloudflare";const app = await alchemy("my-first-app");const worker = await Worker("hello-worker", {entrypoint: "./src/worker.ts",});console.log(`Worker deployed at: ${worker.url}`);await app.finalize(); -
Create your worker code
Create
src/worker.ts
:export default {async fetch(request: Request): Promise<Response> {return Response.json({message: "Hello from Alchemy!",timestamp: new Date().toISOString(),});},}; -
Start development mode
Use the Alchemy CLI to run in development mode with hot reloading:
Terminal window bun alchemy devTerminal window npx alchemy devTerminal window pnpm alchemy devTerminal window yarn alchemy devYour worker will be available locally with live updates as you edit your code.
-
Make a change
Update your worker message in
src/worker.ts
:message: "Hello from Alchemy! 🧪",Save the file and see the change reflected immediately.
-
Deploy to production
Terminal window bun alchemy deployTerminal window npx alchemy deployTerminal window pnpm alchemy deployTerminal window yarn alchemy deployVisit the URL to see your worker live on Cloudflare’s edge network.
-
(Optional) Tear down
Use the Alchemy CLI to delete all of the resources:
Terminal window bun alchemy destroyTerminal window npx alchemy destroyTerminal window pnpm alchemy destroyTerminal window yarn alchemy destroy
You’ve successfully deployed your first Cloudflare Worker with Alchemy! Here are some next steps:
- Learn about the Alchemy CLI - Complete command reference and options
- Deploy a ViteJS site to Cloudflare - Build full-stack applications
- Learn about Cloudflare Workers - Advanced worker features
- Build your own Custom Resource - Extend Alchemy