Performance: Node.js adapter for self-hosting
This affects server-side rendering speed and initial page load time by how efficiently the Node.js adapter handles requests and serves content.
import { createServer } from 'http'; import { handler } from './dist/server/entry.mjs'; const server = createServer(async (req, res) => { // Use streaming response and cache static assets await handler(req, res); }); server.listen(3000);
import { createServer } from 'http'; import { handler } from './dist/server/entry.mjs'; const server = createServer((req, res) => { handler(req, res); // directly calling handler without caching or streaming }); server.listen(3000);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct handler call without streaming | N/A (server-side) | N/A | N/A | [X] Bad |
| Streaming response with caching | N/A (server-side) | N/A | N/A | [OK] Good |
output: 'server' to enable server-side rendering.output: 'server' with adapter: node().node ./dist/server/entry.mjs after building?
{
output: 'server',
adapter: node()
}output: 'server' and adapter: node(), Astro builds a server-ready app.node ./dist/server/entry.mjs starts the Node.js serveroutput: 'server' but forgot to add adapter: node() in your Astro config. What happens when you try to build?output: 'server' is set, an adapter like node() is required to handle server build.adapter: node(), the build process fails with an error indicating the missing adapter.output: 'server' and adapter: node().public/ folder to be served directly by the server.Pass the test and this pattern moves unknown