The Adapter API enables server-side rendering (SSR) for Astro by providing host-specific request handling and build configuration. Use this API to deploy Astro to any cloud provider or edge platform.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/withastro/docs/llms.txt
Use this file to discover all available pages before exploring further.
When to use this API
Use the Adapter API when you need to:- Enable SSR deployment to a specific hosting platform
- Configure build output for serverless functions
- Handle platform-specific request/response formats
- Set up preview servers for testing SSR builds
- Implement host-specific features (edge middleware, image optimization, etc.)
Creating an adapter
An adapter is a special integration that callssetAdapter() in the astro:config:done hook:
Adapter configuration
ThesetAdapter() function accepts an object with the following properties:
Unique name for your adapter, used for logging.
Path to the server entrypoint file that handles rendering.
Map of Astro features supported by the adapter. This allows Astro to provide appropriate error messages.Available features:
staticOutput- Serve static pageshybridOutput- Mix of static and SSR pagesserverOutput- All pages rendered on-demandi18nDomains- i18n domain supportenvGetSecret-astro:env/serversecret supportsharpImageService- Sharp image service support
'stable'- Fully supported'experimental'- Supported but may change'limited'- Partial support'deprecated'- Supported but will be removed'unsupported'- Not supported
Adapter-specific features that change build output:
JSON-serializable value passed to the server entrypoint at runtime. Useful for build-time configuration.
Array of named exports from your server entrypoint’s
createExports() function.Path to a module that starts the preview server when running
astro preview.Building a server entrypoint
The server entrypoint handles rendering at request time. It must export eithercreateExports() or start().
createExports()
Export a function that returns the exports required by your host:The SSR manifest containing routing and build information.
The
args object defined in your adapter configuration.start()
For hosts that require you to start the server (e.g., listening to a port):The App class
Imported fromastro/app, the App class provides methods for rendering:
app.render()
Renders a page and returns aResponse:
Standard
Request object to render.Optional rendering configuration:
app.match()
Determines if a request matches Astro’s routing rules:Static methods
Returns individual cookie header values from a response.
App.validateForwardedHost
(forwardedHost: string, allowedDomains?: RemotePattern[], protocol?: string) => boolean
Validates a forwarded host against allowed domains.
Node.js adapter features
For Node.js environments, useastro/app/node:
NodeApp.createRequest()
Converts Node’sIncomingMessage to a standard Request:
NodeApp.writeResponse()
Streams aResponse to Node’s ServerResponse:
Feature support configuration
Define support levels for Astro features:Adapter features
edgeMiddleware
Prevents middleware from being bundled with every page:astro:build:ssr: