Give feedback as an early user and get the docs plus a full website free. Code FRIEND: valid on one-time purchases only.

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 build

Publish directory

Where the site lands

dist

Two 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 beginners

Connect a repo from GitHub, GitLab, BitBucket, or Azure DevOps. Netlify recognizes Astro and fills in the settings for you.

  1. 1Click Add a new site in your Netlify dashboard.
  2. 2Choose Import an existing project and pick your Git provider.
  3. 3Select the repository you want to deploy.
  4. 4Click Deploy, that's it.

After this, every git push rebuilds your site automatically.

From the terminal

If you prefer the command line

Run these three commands. netlify init detects your Astro settings and walks you through the rest.

terminal
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.

netlify.toml
[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:

terminal
npx astro add netlify
Once it's installed, your server routes and API endpoints deploy automatically as Netlify Functions, no extra setup. Make a landing page render on the server by adding 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.