| 1 | --- |
| 2 | title: Setup |
| 3 | description: Install Alchemy, create a Cloudflare account, and connect the two — OAuth or API token, saved to a local profile. No environment variables required. |
| 4 | --- |
| 5 | |
| 6 | import { Code, Tabs, TabItem } from "@astrojs/starlight/components"; |
| 7 | import { effectVersion } from "../../../versions"; |
| 8 | |
| 9 | export const pkgs = `"alchemy@latest" "effect@${effectVersion}" "@effect/platform-bun@${effectVersion}" "@effect/platform-node@${effectVersion}"`; |
| 10 | |
| 11 | Everything you need before deploying to Cloudflare: the alchemy |
| 12 | package, a Cloudflare account, and stored credentials. |
| 13 | |
| 14 | ## Install |
| 15 | |
| 16 | Install <code>alchemy@latest</code> and <code>effect@{effectVersion}</code> |
| 17 | in your project: |
| 18 | |
| 19 | <Tabs syncKey="pkgManager"> |
| 20 | <TabItem label="bun" icon="bun"> |
| 21 | <Code code={`bun add ${pkgs}`} lang="sh" /> |
| 22 | </TabItem> |
| 23 | <TabItem label="npm" icon="npm"> |
| 24 | <Code code={`npm install ${pkgs}`} lang="sh" /> |
| 25 | </TabItem> |
| 26 | <TabItem label="pnpm" icon="pnpm"> |
| 27 | <Code code={`pnpm add ${pkgs}`} lang="sh" /> |
| 28 | </TabItem> |
| 29 | <TabItem label="yarn" icon="seti:yarn"> |
| 30 | <Code code={`yarn add ${pkgs}`} lang="sh" /> |
| 31 | </TabItem> |
| 32 | </Tabs> |
| 33 | |
| 34 | Alchemy runs on [Bun](https://bun.sh) or Node.js 22+. |
| 35 | |
| 36 | ## Create a Cloudflare account |
| 37 | |
| 38 | If you don't have one yet, |
| 39 | [sign up for Cloudflare](https://dash.cloudflare.com/sign-up) — the |
| 40 | free plan is enough for everything in the tutorial. |
| 41 | |
| 42 | ## Connect alchemy to Cloudflare |
| 43 | |
| 44 | Connect Cloudflare (the `default` profile is created automatically on |
| 45 | first use): |
| 46 | |
| 47 | ```sh |
| 48 | alchemy profile edit --add Cloudflare |
| 49 | ``` |
| 50 | |
| 51 | For Cloudflare you can: |
| 52 | |
| 53 | - **Sign in with OAuth** — opens the browser, no tokens to manage. |
| 54 | - **Paste an API token** — if you prefer explicit, scoped tokens. |
| 55 | |
| 56 | The OAuth flow asks whether you want to customize scopes — answer |
| 57 | yes to pick exactly which ones to grant at a multiselect prompt (the |
| 58 | default set covers typical use). |
| 59 | |
| 60 | Either way the result is saved to your **`default`** |
| 61 | [profile](/environments/profiles) at `~/.alchemy/profiles.json` — no |
| 62 | environment variables and no `wrangler login` required. |
| 63 | |
| 64 | To re-run the flow later: |
| 65 | |
| 66 | ```sh |
| 67 | # Re-run the interactive setup (e.g. switch from OAuth → API token) |
| 68 | alchemy profile edit --reconfigure Cloudflare |
| 69 | |
| 70 | # Or manage every account in the profile from one menu |
| 71 | alchemy profile edit |
| 72 | ``` |
| 73 | |
| 74 | `profile edit` imports your stack file to discover which providers |
| 75 | are available, so the menu matches the providers you actually use. |
| 76 | |
| 77 | ## Profiles |
| 78 | |
| 79 | A profile is a named bundle of credentials. Commands use the built-in |
| 80 | `default` profile unless you name another one explicitly. |
| 81 | Pass `--profile <name>` or set `$ALCHEMY_PROFILE` to select one — |
| 82 | handy for separating work and personal accounts, or staging and prod credentials: |
| 83 | |
| 84 | ```sh |
| 85 | # Log into a separate profile |
| 86 | alchemy profile create prod |
| 87 | alchemy profile edit --profile prod |
| 88 | |
| 89 | # Deploy with it |
| 90 | alchemy deploy --stage prod --profile prod |
| 91 | ``` |
| 92 | |
| 93 | Inspect what's stored (credentials are redacted) with: |
| 94 | |
| 95 | ```sh |
| 96 | alchemy profile show |
| 97 | ``` |
| 98 | |
| 99 | See [Profiles](/environments/profiles) for the full picture. |
| 100 | |
| 101 | :::note[Running in CI?] |
| 102 | CI environments can't do interactive logins. There, alchemy reads |
| 103 | credentials from the environment instead: `CLOUDFLARE_ACCOUNT_ID` |
| 104 | plus either `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_API_KEY` + |
| 105 | `CLOUDFLARE_EMAIL` (or `CLOUDFLARE_ACCOUNT_EMAIL`). See the [CI guide](/environments/ci) for the full |
| 106 | GitHub Actions setup. |
| 107 | ::: |
| 108 | |
| 109 | ## Where next |
| 110 | |
| 111 | - [Tutorial part 1](/cloudflare/tutorial/part-1) — create a Stack, |
| 112 | deploy your first resource. |
| 113 | - [Cloudflare overview](/cloudflare) — the map of resources and |
| 114 | guides. |
| 115 | - [Secrets & env](/cloudflare/security/secrets-env) — wire `.env` values and |
| 116 | secrets into your Workers (deploy credentials live in your profile; |
| 117 | app secrets are bindings). |