sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ getting-started.mdx

import Terminal from "../../components/Terminal.astro";
import PackageManagers from "../../components/PackageManagers.astro";
export const pkgs = `alchemy@latest @alchemy.run/cloudflare@latest effect @effect/platform-bun @effect/platform-node`;

:::tip Want the idea before the install? What is Alchemy? explains the model in a few minutes. Otherwise, read on and it's the next page. :::

Prerequisites

Create a project

Install

Create your Stack

Every Alchemy program starts with a Stack — create alchemy.run.ts:

// alchemy.run.ts
import * as Alchemy from "alchemy";
import * as Cloudflare from "@alchemy.run/cloudflare";
import * as Effect from "effect/Effect";

export default Alchemy.Stack(
  "MyApp",
  {
    providers: Cloudflare.providers(),
    state: Cloudflare.state(),
  },
  Effect.gen(function* () {
    const bucket = yield* Cloudflare.R2.Bucket("Bucket");

    return {
      bucketName: bucket.bucketName,
    };
  }),
);

Deploy

Run alchemy deploy to create the Bucket on Cloudflare:

Connect Cloudflare first with alchemy profile edit --add Cloudflare. Sign in with OAuth in the browser or paste an API token. The credentials are saved to your default profile at ~/.alchemy/profiles.json. No environment variables required. Logging in only ever happens through the profile command; a deploy with nothing configured fails with the exact command to run.

Once you're authenticated, Alchemy shows a plan, asks for confirmation, and provisions the resource:

<Terminal content={`[u]Plan[/u]: [g]1 to create[/g] [g]+[/g] [b]Bucket[/b] d[/d]

Proceed? ◉ Yes ○ No [g]✓[/g] [b]Bucket[/b] d[/d] [g]created[/g] { [s2]bucketName: "myapp-bucket-a1b2c3d4e5", }`} />

That's it — you have a live R2 Bucket on Cloudflare.

Full command reference: CLI.

:::tip To re-run the credential prompt later (e.g. to switch from OAuth to an API token), use alchemy profile edit --reconfigure Cloudflare. For a separate profile, run alchemy profile create prod followed by alchemy profile edit --profile prod. See Profiles for the full picture. :::

Where next

You have a live Stack. What is Alchemy? explains what just happened and the model the rest of the docs build on. The tutorial then builds a full app on Cloudflare, starting from this exact Stack.

What is Alchemy? Your infrastructure and the code that runs on it, built with Effects and Layers. Tutorial Build a full app on Cloudflare starting from this Stack: a Worker, bindings, tests, local dev, CI, and telemetry. Infrastructure as Effects The model the rest of the docs build on: Runtimes, Bindings, Layers, and the Construction and Runtime phases. Cloudflare Workers, Durable Objects, R2, KV, D1, Queues, Workflows, and Containers, with a tutorial and a guide for each. AWS Lambda, S3, SQS, DynamoDB, EC2, ECS, and EKS, with a tutorial and a guide for each. CLI Every command and its flags: deploy, plan, destroy, dev, tail, logs, and state.