Open-Source Wikis

/

Astro

/

Packages

/

Server adapters

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:

  1. Detect the platform. Read process.env, import.meta.env, or platform-specific globals.
  2. Configure the build. Tell Astro which files to emit, where, and what target (e.g. Node, Edge, Workers).
  3. Provide a runtime entrypoint. Translate the platform's request type to a Request, hand it to app.render(), translate the Response back.
  4. 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| C

The 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 a server.mjs that 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:assets is 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_compat opts in to a curated subset).
  • prerender environment configurable per route (feat(cloudflare): configure prerender environment, commit b2bd27b).
  • allowedHosts is forwarded to the preview entrypoint (feat: pass allowedHosts to cloudflare preview entrypoint, commit a49637a).
  • Uses workerd (allowed in pnpm.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.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Server adapters – Astro wiki | Factory