Introduction
The Node.js adapter lets you run your Astro site on your own server using Node.js. It helps connect your site to the server so it can work smoothly.
The Node.js adapter lets you run your Astro site on your own server using Node.js. It helps connect your site to the server so it can work smoothly.
import { defineConfig } from 'astro/config'; import node from '@astrojs/node'; export default defineConfig({ adapter: node(), });
import node from '@astrojs/node'; export default { adapter: node(), };
mode: 'standalone' to bundle dependencies for easier deployment.import { defineConfig } from 'astro/config'; import node from '@astrojs/node'; export default defineConfig({ adapter: node({ mode: 'standalone', }), });
This is a complete Astro config using the Node.js adapter for self-hosting. It sets the adapter and the site URL.
import { defineConfig } from 'astro/config'; import node from '@astrojs/node'; export default defineConfig({ adapter: node(), site: 'https://example.com', });
After building, run node ./dist/server/index.js to start your site.
Make sure Node.js is installed on your server to use this adapter.
This adapter supports server-side rendering for dynamic content.
The Node.js adapter lets Astro sites run on your own Node.js server.
Add it in your Astro config to prepare your site for self-hosting.
It enables server-side rendering and custom server logic.
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