How to Use Render with Astro: Complete Guide
Step-by-step guide to integrating Render with your Astro website.
Render is a cloud application hosting platform that focuses on simplicity. It provides automatic deploys from Git, managed databases, free SSL, and a straightforward dashboard. For Astro developers, Render offers two relevant options: free static site hosting for pre-rendered Astro sites, and web services starting at $7/month for SSR deployments. If you have tried Heroku and wished it were simpler and cheaper, Render is the modern alternative.
The deployment process is clean. Connect your Git repo, tell Render how to build your project, and it handles the rest. No Docker files, no infrastructure config, no YAML pipelines.
Prerequisites
- Node.js 18+
- An Astro project (
npm create astro@latest) - A Render account (free tier for static sites)
- Your project in a GitHub or GitLab repository
Installation
For a static Astro site, no extra packages are needed. Just make sure your Astro config outputs static files:
// astro.config.mjs
import { defineConfig } from "astro/config";
export default defineConfig({
output: "static", // This is the default
});
For SSR deployments, install the Node adapter:
npm install @astrojs/node
Then configure Astro to use it:
// astro.config.mjs
import { defineConfig } from "astro/config";
import node from "@astrojs/node";
export default defineConfig({
output: "server",
adapter: node({
mode: "standalone",
}),
});
Configuration
For static sites, go to Render's dashboard and create a new "Static Site":
- Connect your GitHub or GitLab repository
- Set the build command:
npm run build - Set the publish directory:
dist
That is it. Render detects the Node.js environment, runs your build, and serves the output from its CDN.
For SSR sites, create a "Web Service" instead and configure the start command:
# Build command
npm run build
# Start command
node ./dist/server/entry.mjs
Add a render.yaml to your project root for infrastructure-as-code:
# render.yaml
services:
- type: web
name: my-astro-site
runtime: node
buildCommand: npm install && npm run build
startCommand: node ./dist/server/entry.mjs
envVars:
- key: NODE_ENV
value: production
- key: PORT
value: "8080"
For static sites, the render.yaml looks simpler:
# render.yaml
services:
- type: web
name: my-astro-site
runtime: static
buildCommand: npm install && npm run build
staticPublishPath: ./dist
headers:
- path: /*
name: X-Frame-Options
value: DENY
Environment variables are configured through the Render dashboard or the render.yaml file:
# In Render Dashboard > Environment
SITE_URL=https://yourdomain.com
API_KEY=your-api-key
Basic Usage
After connecting your repo, every push to your main branch triggers an automatic deploy. The typical workflow looks like this:
# Make changes locally
git add .
git commit -m "Add new blog post"
git push origin main
# Render automatically builds and deploys
For custom domains, go to your Render service settings and add your domain. Render automatically provisions an SSL certificate via Let's Encrypt.
You can set up a custom 404 page for static sites by adding a redirect rule in the Render dashboard:
Source: /*
Destination: /404.html
Status: 404
For SSR deployments, handle 404s in your Astro middleware or create a src/pages/404.astro page that Astro serves automatically.
Health checks work out of the box for web services. Render pings your service and restarts it if it becomes unresponsive:
// src/pages/health.ts (for SSR sites)
import type { APIRoute } from "astro";
export const GET: APIRoute = async () => {
return new Response(JSON.stringify({ status: "ok" }), {
status: 200,
headers: { "Content-Type": "application/json" },
});
};
Production Tips
Use Render's free static hosting for blogs. Static Astro sites deploy for free on Render with unlimited bandwidth on the free tier. This is perfect for blogs, documentation sites, and marketing pages.
Set up deploy hooks for CMS-triggered rebuilds. If you use a headless CMS, get a deploy hook URL from Render (under your service settings) and configure your CMS webhook to hit it whenever content changes. This triggers an automatic rebuild.
Enable auto-scaling for SSR. Render supports auto-scaling on paid plans. If your SSR Astro site handles traffic spikes, configure minimum and maximum instances to scale automatically without manual intervention.
Use preview environments. Render can create a new deployment for every pull request. Enable "Pull Request Previews" in your service settings to let your team review changes on a unique URL before merging.
Keep builds fast with caching. Render caches your
node_modulesbetween builds. Make sure you are using a lockfile (package-lock.json) so the cache works correctly and builds stay fast.
Alternatives to Consider
- Vercel if you want zero-config Astro deployment with edge functions and image optimization built in.
- Netlify if you need a similar experience with more built-in features like form handling and identity management.
- Railway if you need databases and background workers alongside your Astro site in a single platform.
Wrapping Up
Render is a clean, no-nonsense hosting platform that works well for both static and SSR Astro sites. The free tier for static sites is genuinely useful, not just a marketing gimmick, and the paid web services are reasonably priced for SSR deployments. The interface stays out of your way, deploys are fast, and the infrastructure-as-code option with render.yaml keeps your deployment config versioned alongside your application code. If you want straightforward hosting without the complexity of AWS or the vendor-specific features of Vercel, Render is a solid middle ground.
Related Articles
How to Use Algolia with Astro: Complete Guide
Step-by-step guide to integrating Algolia with your Astro website.
How to Integrate Auth0 with Astro: Complete Guide
Step-by-step guide to integrating Auth0 with your Astro website. Setup, configuration, and best practices.
How to Use AWS Amplify with Astro: Complete Guide
Step-by-step guide to integrating AWS Amplify with your Astro website.