To deploy Astro to Render, create a Static Site, connect your Git repository, set the build command to npm ci && npm run build and the publish directory to dist. Render builds on every push to the branch you choose and serves the result from its CDN. For on-demand rendering, use a Web Service with the @astrojs/node adapter instead.
Key Takeaways
- Static Astro sites deploy to Render as a Static Site: build
npm ci && npm run build, publishdist.- Pin Node.js with a
NODE_VERSIONenvironment variable or a.node-versionfile; current Astro needs 22.23.4 or newer.- Redirects, rewrites and headers are configured in Render’s dashboard or
render.yaml, not in a_headersfile.- Pull request previews are available for static sites once you turn them on.
Static site setup
- In the Render dashboard, choose New and then Static Site, and connect your GitHub, GitLab or Bitbucket repository.
- Set Build Command to
npm ci && npm run build. - Set Publish Directory to
dist. - Under Environment, add
NODE_VERSIONwith a value such as22.23.4or newer. - Create the site. Render gives it an
onrender.comsubdomain; add your own domain under Settings.
Set site in astro.config.mjs to the final domain before your first production deploy, so canonical URLs and the sitemap point at it. See our site option tip.
Instead of the environment variable, you can commit the Node.js version:
# .node-version
22.23.4
Infrastructure as code with render.yaml
A blueprint keeps the settings in your repository:
# render.yaml
services:
- type: web
runtime: static
name: my-astro-site
buildCommand: npm ci && npm run build
staticPublishPath: ./dist
envVars:
- key: NODE_VERSION
value: 22.23.4
headers:
- path: /_astro/*
name: Cache-Control
value: public, max-age=31536000, immutable
routes:
- type: redirect
source: /old-blog/*
destination: /blog/*
Create it from New and then Blueprint in the dashboard. Render’s blueprint reference lists every field; check it if a key is rejected, since the schema evolves.
404 pages and trailing slashes
Render serves dist/404.html for missing paths when the file exists, so a src/pages/404.astro page is all you need. Do not add a catch-all rewrite to /index.html; that is for single-page apps and would hide real 404s. Our custom 404 tip covers the page itself.
Headers and redirects
Render does not read Netlify-style _headers or _redirects files. Add headers and redirects in the static site’s Redirects/Rewrites and Headers settings, or in render.yaml as above. For redirects that live in your code, Astro’s redirects option in astro.config.mjs generates HTML redirect pages that work on any host; see our redirects tip.
SSR on a Render Web Service
If you use on-demand rendering, add the Node adapter:
// astro.config.mjs
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
export default defineConfig({
site: 'https://www.example.com',
adapter: node({ mode: 'standalone' }),
});
Then create a Web Service with build command npm ci && npm run build and start command node ./dist/server/entry.mjs. Add the environment variable HOST=0.0.0.0. Render sets PORT for you and the standalone server reads it. Free web services spin down when idle, so the first request after a pause is slow; static sites do not have that problem.
Preview deployments
In the static site’s settings, enable pull request previews. Each pull request gets its own URL that updates on every push. Our preview deployments tip covers keeping previews out of search results. For a comparison of hosts, read free hosting for Astro and the static deploy docs. Themes from our Astro theme catalog deploy as Render Static Sites with these exact settings.
FAQ
What build command and publish directory does Astro use on Render?
Build command npm ci && npm run build, publish directory dist. If you changed outDir in astro.config.mjs, use that folder instead.
How do I set the Node.js version for Astro on Render?
Add a NODE_VERSION environment variable or commit a .node-version file. Current Astro releases need Node.js 22.23.4 or newer.
Is Render free for Astro sites?
Render offers free static sites with bandwidth limits. Check Render’s current pricing page for the exact allowances.
Does Render support Astro SSR?
Yes, as a Web Service. Use @astrojs/node in standalone mode, start with node ./dist/server/entry.mjs, and set HOST=0.0.0.0.