Performance: Deploying to Netlify
This affects the initial page load speed and ongoing site responsiveness by how the site is built and served from Netlify's CDN.
export default {
output: 'static'
} // in astro.config.mjs
astro build
# Deploy static output folder to Netlify for CDN deliveryexport default {
output: 'server'
} // in astro.config.mjs
astro build
# Deploying server output to Netlify without static optimization| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Server-side rendering on Netlify | N/A (server-generated) | N/A | Higher due to delayed HTML arrival | [X] Bad |
| Static site deployment on Netlify | N/A (static HTML) | N/A | Lower due to fast CDN delivery | [OK] Good |
netlify.toml to set build commands and publish directories.package.json manages dependencies, astro.config.mjs configures Astro, and index.html is a page file.netlify.toml snippet:[build] command = "npm run build" publish = "dist"
npm run build tells Netlify how to build the site before publishing.publish folder dist is where the built site files are located for Netlify to serve.publish folder is wrong, Netlify serves an empty or wrong folder causing 404 errors.index.html is inside the publish folder, not root.npm run build) and publish folder (e.g., dist) in Netlify.Pass the test and this pattern moves unknown