Installation
Install the required dependencies:Configuration
import alchemy from "alchemy/cloudflare/astro";
import { defineConfig } from "astro/config";
export default defineConfig({
output: "server",
adapter: alchemy(),
});
import alchemy from "alchemy";
import { Astro, D1Database } from "alchemy/cloudflare";
const app = await alchemy("my-astro-app");
const db = await D1Database("database", {
name: `${app.name}-${app.stage}-db`,
});
const website = await Astro("website", {
bindings: {
DB: db,
},
});
console.log({
url: website.url,
});
await app.finalize();
Configuration Options
Properties
output(optional): Astro output mode"server"- Server-side rendering (default if adapter is used)"static"- Static site generation- Auto-detected from
astro.config.mjs
bindings: Cloudflare bindings (KV, R2, D1, etc.)build: Build command override- Default:
astro build
- Default:
dev: Dev command override- Default:
astro dev
- Default:
entrypoint: Worker entrypoint path- Default:
dist/_worker.js/index.js(server mode)
- Default:
assets: Static assets directory- Default:
dist
- Default:
Static vs Server Mode
Static Site
For static sites, setoutput: "static" in your Astro config:
Server-Side Rendering
For SSR, setoutput: "server" and use the adapter:
Accessing Bindings
Access Cloudflare bindings in your Astro pages:Local Development
The Alchemy adapter automatically:- Configures platform proxy for local bindings
- Ignores
.alchemydirectory from file watching - Provides development environment access
Related Resources
- Website - Base resource for web applications
- D1 Database - SQL database
- KV Namespace - Key-value storage