Skip to content
GitHubXDiscord

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.

  1. Create your project

    Start by creating a new project and installing Alchemy.

    Terminal window
    mkdir my-alchemy-app
    cd my-alchemy-app
    Terminal window
    bun init -y
    bun add alchemy
    bun add -g alchemy wrangler
  2. Login to Cloudflare

    Authenticate with your Cloudflare account.

    Terminal window
    bun wrangler login
  3. 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();
  4. 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(),
    });
    },
    };
  5. Start development mode

    Use the Alchemy CLI to run in development mode with hot reloading:

    Terminal window
    bun alchemy dev

    Your worker will be available locally with live updates as you edit your code.

  6. Make a change

    Update your worker message in src/worker.ts:

    message: "Hello from Alchemy! 🧪",

    Save the file and see the change reflected immediately.

  7. Deploy to production

    Terminal window
    bun alchemy deploy

    Visit the URL to see your worker live on Cloudflare’s edge network.

  8. (Optional) Tear down

    Use the Alchemy CLI to delete all of the resources:

    Terminal window
    bun alchemy destroy

You’ve successfully deployed your first Cloudflare Worker with Alchemy! Here are some next steps: