Deploy your Astro site to Netlify
Netlify hosts websites for free and updates them automatically every time you push to Git. Any Astro site works on Netlify, this guide walks you through it step by step.
Build settings
Netlify fills these in automatically when you import an Astro project, so you usually don't have to touch them:
Build command
Compiles your site
$npm run buildPublish directory
Where the site lands
distTwo ways to deploy
Both get your site live. If you're new, start with the website, it's all clicks, no terminal.
From the website
Recommended for beginnersConnect a repo from GitHub, GitLab, BitBucket, or Azure DevOps. Netlify recognizes Astro and fills in the settings for you.
- 1Click Add a new site in your Netlify dashboard.
- 2Choose Import an existing project and pick your Git provider.
- 3Select the repository you want to deploy.
- 4Click Deploy, that's it.
After this, every git push rebuilds your site automatically.
From the terminal
If you prefer the command lineRun these three commands. netlify init detects your Astro settings and walks you through the rest.
npm install --global netlify-cli netlify login netlify init
Once linked, your site rebuilds automatically every time you git push.
Set the build in a file
Want your settings saved in your repo instead of the dashboard? Add a netlify.toml file to the root of your project. Netlify reads it on every deploy.
[build] command = "npm run build" publish = "dist"
Need a server? Add the adapter
By default your Astro site is fully static, perfect for most projects, and nothing extra to set up. Only add the Netlify adapter if you need server features like API routes or pages that render on each request. One command installs and configures it:
npx astro add netlify
export const prerender = false to it.Build failing? Check your Node version
Astro needs Node 22.12.0 or newer. If your build fails, add an .nvmrc file containing 22.12.0 to your project root, or set a NODE_VERSION variable in your Netlify settings.
Learn more
The official docs go deeper if you need them.
