The best way to control Claude Code, Codex and more from any computer or phone

main
mdx 137 lines 4.02 KB
Raw
1 ---
2 title: Getting started
3 description: Install Alchemy and create your first Stack in under two minutes.
4 next:
5 link: /what-is-alchemy
6 label: What is Alchemy?
7 ---
8
9 import Terminal from "../../components/Terminal.astro";
10 import PackageManagers from "../../components/PackageManagers.astro";
11
12 export const pkgs = `alchemy@latest @alchemy.run/cloudflare@latest effect @effect/platform-bun @effect/platform-node`;
13
14 :::tip
15 Want the idea before the install? [What is Alchemy?](/what-is-alchemy)
16 explains the model in a few minutes. Otherwise, read on and it's the
17 next page.
18 :::
19
20 ## Prerequisites
21
22 - [Bun](https://bun.sh) or Node.js 24.11.1+
23 - A [Cloudflare](https://dash.cloudflare.com/sign-up) account
24
25 ## Create a project
26
27 <PackageManagers init dir="my-app" />
28
29 ## Install
30
31 <PackageManagers add={pkgs} />
32
33 ## Create your Stack
34
35 Every Alchemy program starts with a Stack — create `alchemy.run.ts`:
36
37 ```typescript
38 // alchemy.run.ts
39 import * as Alchemy from "alchemy";
40 import * as Cloudflare from "@alchemy.run/cloudflare";
41 import * as Effect from "effect/Effect";
42
43 export default Alchemy.Stack(
44 "MyApp",
45 {
46 providers: Cloudflare.providers(),
47 state: Cloudflare.state(),
48 },
49 Effect.gen(function* () {
50 const bucket = yield* Cloudflare.R2.Bucket("Bucket");
51
52 return {
53 bucketName: bucket.bucketName,
54 };
55 }),
56 );
57 ```
58
59 ## Deploy
60
61 Run `alchemy deploy` to create the Bucket on Cloudflare:
62
63 <PackageManagers run="alchemy deploy" />
64
65 Connect Cloudflare first with `alchemy profile edit --add Cloudflare`.
66 Sign in with OAuth in the browser or paste an API token. The
67 credentials are saved to your **`default`**
68 [profile](/environments/profiles) at `~/.alchemy/profiles.json`. No
69 environment variables required. Logging in only ever happens through the
70 `profile` command; a deploy with nothing configured fails with the exact
71 command to run.
72
73 Once you're authenticated, Alchemy shows a plan, asks for
74 confirmation, and provisions the resource:
75
76 <Terminal content={`[u]Plan[/u]: [g]1 to create[/g]
77 [g]+[/g] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d]
78
79 Proceed?
80 ◉ Yes ○ No
81 [g]✓[/g] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d] [g]created[/g]
82 {
83 [s2]bucketName: "myapp-bucket-a1b2c3d4e5",
84 }`} />
85
86 That's it — you have a live R2 Bucket on Cloudflare.
87
88 Full command reference: [CLI](/cli).
89
90 :::tip
91 To re-run the credential prompt later (e.g. to switch from OAuth to
92 an API token), use `alchemy profile edit --reconfigure Cloudflare`.
93 For a separate profile, run `alchemy profile create prod` followed by
94 `alchemy profile edit --profile prod`.
95 See [Profiles](/environments/profiles) for the full picture.
96 :::
97
98 ## Where next
99
100 You have a live Stack. [What is Alchemy?](/what-is-alchemy) explains
101 what just happened and the model the rest of the docs build on. The
102 [tutorial](/cloudflare/tutorial/part-1) then builds a full app on
103 Cloudflare, starting from this exact Stack.
104
105 <div class="next-steps">
106
107 <a href="/what-is-alchemy" class="next-card next-card--recommended">
108 <strong>What is Alchemy?</strong>
109 <span>Your infrastructure and the code that runs on it, built with Effects and Layers.</span>
110 </a>
111
112 <a href="/cloudflare/tutorial/part-1" class="next-card">
113 <strong>Tutorial</strong>
114 <span>Build a full app on Cloudflare starting from this Stack: a Worker, bindings, tests, local dev, CI, and telemetry.</span>
115 </a>
116
117 <a href="/infrastructure-as-effects/runtime" class="next-card">
118 <strong>Infrastructure as Effects</strong>
119 <span>The model the rest of the docs build on: Runtimes, Bindings, Layers, and the Construction and Runtime phases.</span>
120 </a>
121
122 <a href="/cloudflare" class="next-card">
123 <strong>Cloudflare</strong>
124 <span>Workers, Durable Objects, R2, KV, D1, Queues, Workflows, and Containers, with a tutorial and a guide for each.</span>
125 </a>
126
127 <a href="/aws" class="next-card">
128 <strong>AWS</strong>
129 <span>Lambda, S3, SQS, DynamoDB, EC2, ECS, and EKS, with a tutorial and a guide for each.</span>
130 </a>
131
132 <a href="/cli" class="next-card">
133 <strong>CLI</strong>
134 <span>Every command and its flags: deploy, plan, destroy, dev, tail, logs, and state.</span>
135 </a>
136
137 </div>