This adapter allows Astro to deploy your SSR site to Node targets.
Why Astro NodeSection titled Why Astro Node
If you’re using Astro as a static site builder—its behavior out of the box—you don’t need an adapter.
If you wish to use server-side rendering (SSR), Astro requires an adapter that matches your deployment runtime.
InstallationSection titled Installation
Add the Node adapter to enable SSR in your Astro project with the following
astro add command. This will install the adapter and make the appropriate changes to your
astro.config.mjs file in one step.
If you prefer to install the adapter manually instead, complete the following two steps:
Install the Node adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
Add two new lines to your
astro.config.mjsproject configuration file.
UsageSection titled Usage
Using a middleware frameworkSection titled Using a middleware framework
You can use this
handler with any framework that supports the Node
For example, with Express:
Using Section titled Using http
This output script does not require you use Express and can work with even the built-in
https node modules. The handler does follow the convention calling an error function when either
- A route is not found for the request.
- There was an error rendering.
You can use these to implement your own 404 behavior like so:
ConfigurationSection titled Configuration
This adapter does not expose any configuration options.
TroubleshootingSection titled Troubleshooting
For help, check out the
#support channel on Discord. Our friendly Support Squad members are here to help!
You can also check our Astro Integration Documentation for more on integrations.
ContributingSection titled Contributing
This package is maintained by Astro’s Core team. You’re welcome to submit an issue or PR!
ChangelogSection titled Changelog
See CHANGELOG.md for a history of changes to this integration.