withastro/astro
Server adapters
Adapters wrap the Astro production runtime (packages/astro/src/core/app/) for a specific deployment platform. They register themselves via setAdapter() in the astro:config:done hook and emit a runtime entrypoint during the build.
Anatomy of an adapter
Every adapter does roughly the same four things:
- Detect the platform. Read
process.env,import.meta.env, or platform-specific globals. - Configure the build. Tell Astro which files to emit, where, and what target (e.g. Node, Edge, Workers).
- Provide a runtime entrypoint. Translate the platform's request type to a
Request, hand it toapp.render(), translate theResponseback. - Optionally provide a preview server (
astro preview).
graph LR
A[Platform request<br/>http.IncomingMessage / Workers Request / etc.] --> B[Adapter entry]
B -->|new Request(url, init)| C[App.render]
C -->|Response| D[Adapter entry]
D -->|res.write / Response / etc.| E[Platform response]
F[SSRManifest] -->|injected at build| CThe serialized SSRManifest is produced by packages/astro/src/core/app/manifest.ts and embedded into the adapter's emitted entrypoint.
@astrojs/node (packages/integrations/node/)
The Node.js adapter. Two modes:
mode: 'standalone'— emits aserver.mjsthat boots a real HTTP server.mode: 'middleware'— emits a handler exporting(req, res, next) => …for use with Express, Connect, Polka, or a custom dispatcher.
packages/astro/src/core/app/node.ts is the shared Node adapter glue (request translation, header normalization, body streaming).
@astrojs/vercel (packages/integrations/vercel/)
Targets Vercel's serverless and edge runtimes. Emits one function per route group plus an output.json that Vercel's build system understands. Supports:
- ISR (incremental static regeneration) via
experimentalStaticHeaders. - Edge runtime mode where supported (no Node APIs).
- Image optimization via Vercel's image service when
astro:assetsis configured to defer. - Web Analytics and Speed Insights config helpers.
@astrojs/netlify (packages/integrations/netlify/)
Targets Netlify's runtime. Builds a _redirects file via @astrojs/underscore-redirects (packages/underscore-redirects/), emits Netlify Functions or Edge Functions, and supports image CDN integration.
@astrojs/cloudflare (packages/integrations/cloudflare/)
Targets Cloudflare Workers (and historically Pages). Notable constraints:
- No Node APIs (compatibility flag
nodejs_compatopts in to a curated subset). prerenderenvironment configurable per route (feat(cloudflare): configure prerender environment, commitb2bd27b).allowedHostsis forwarded to the preview entrypoint (feat: pass allowedHosts to cloudflare preview entrypoint, commita49637a).- Uses
workerd(allowed inpnpm.onlyBuiltDependencies) to run integration tests locally.
This adapter is the canonical reason Astro keeps the runtime/non-runtime split strict. The optimizeDeps deep dive in reference is largely about making astro dev behave consistently with the Cloudflare runtime.
@astrojs/deno
packages/integrations/deno/ is a stub — the actively-maintained Deno adapter lives outside the monorepo.
Related pages
- systems / build pipeline
- systems / render context
- packages / internal helpers —
@astrojs/underscore-redirectslives here.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.