Cloudflare
To deploy on Cloudflare Pages, we need to make some package changes and adjust the Astro config file.
- Install the
@astrojs/cloudflare
adapter and uninstall the@astrojs/netlify
adapter - Adjust the
astro.config.mjs
file for Cloudflare Pages deployment - You can also delete the
netlify.toml
file
Project Adjustments
Packages
- Install the
@astrojs/cloudflare
adapter withnpm install @astrojs/cloudflare
- Uninstall the
@astrojs/netlify
adapter withnpm uninstall @astrojs/netlify
Config File
Make the following adjustments to the astro.config.mjs
file for Cloudflare deployment. Note the additional compatibility requirements for Cloudflare Pages:
Test Build
Before deploying, it is recommended to test the build locally with npm run build
to ensure everything is working as expected.
Deploying
- Push your code to GitHub
- Create a Cloudflare account if you don’t already have one
- Follow the official Cloudflare documentation to deploy your site
- Set the build command to
npm run build
- Set the publish directory to
dist
- Set the build command to