Astro

Node adapter

Node adapter is the Astro adapter that builds your on-demand site into a Node server you run yourself. It works in standalone mode or as middleware inside Express or similar.

How it is measured

Set the adapter with a mode, standalone or middleware. Standalone writes dist/server/entry.mjs, which you start with node. It reads HOST and PORT from the environment and serves static files and on-demand routes together.

Test with node ./dist/server/entry.mjs and request a page. Check memory and response time under a few dozen concurrent requests, since this process stays alive.

Worked example

A school district runs Astro on a single VM behind nginx. The Node adapter starts on port 4321 and serves 900 static pages plus a staff login. Idle memory sits at 78 MB.

An update rolls out and the process restarts for 3 seconds. nginx returns 502 for that window until the team adds a health check and a second instance.

How it differs

The Node adapter gives you a process you must keep running. The Cloudflare adapter gives you a Worker the platform runs for you. Node excludes managed scaling; Cloudflare excludes arbitrary Node modules.

Common errors

Forgetting to set HOST and exposing the wrong interface. Running without a process manager. Serving static assets from Node when a CDN would do. Skipping graceful restarts. Ignoring memory growth.

In practice

Run it under a process manager and put a reverse proxy in front. Serve hashed assets with long cache headers. Add a health route and watch memory for a week.

See also

Astro adapter, Cloudflare adapter

Sources

Count this on a real site.

Watch my website