Deploying Astro to Cloudflare Pages
A step-by-step guide on how to deploy your Astro project to Cloudflare Pages.
A step-by-step guide on how to deploy your Astro project to Cloudflare Pages.
Deploying an Astro project to Cloudflare Pages is incredibly simple. In this guide, we’ll walk through the steps to get your site live on the edge.
First, you need to install the @astrojs/cloudflare adapter. You can do this using the Astro CLI:
npx astro add cloudflare
This command will automatically update your astro.config.mjs file to include the adapter.
If you prefer to do it manually, your astro.config.mjs should look something like this:
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
export default defineConfig({
output: 'server',
adapter: cloudflare({
platformProxy: {
enabled: true
}
}),
});
Commit your changes and push your project to a GitHub repository.
Cloudflare will now build and deploy your Astro site! Every time you push to your repository, Cloudflare will automatically trigger a new build.
That’s it! Your Astro site is now running on Cloudflare’s global edge network, providing blazing fast performance for users around the world.