@deno/astro-adapter

中文文档
0.6.0发布于 2026/07/02MITES Module零依赖构建来源已验证近 30 天下载 1.7万

Deploy your Astro site to a Deno server

原始使用文档
文档目录9 节
  1. Overview
  2. Why Astro Deno
  3. Installation
  4. Usage
  5. Configuration
  6. start
  7. port and hostname
  8. Examples
  9. Contributing

@deno/astro-adapter

This adapter allows Astro to run your SSR site in Deno. Astro 6 works in Deno runtime (without Node).

Learn how to deploy your Astro site in our Deno Deploy guide.

Overview

Why Astro Deno

Deno is a runtime similar to Node, but with an API that's more similar to the browser's API. This adapter provides access to Deno's API and creates a script to run your project on a Deno server.

  • Are you using Astro as a static site builder?
    No, you don't need an adapter

  • Are you using Astro server-side rendering (SSR)?
    Yes, you need an adapter

  • Do you wish to deploy your site to Deno Deploy?
    Yes, you also need an adapter

Installation

Add the Deno adapter to enable SSR in your Astro project with the following steps:

1. Add an adapter

deno add npm:@deno/astro-adapter

2. Update your astro.config.mjs file

// astro.config.mjs
import { defineConfig } from "astro/config";
import deno from "@deno/astro-adapter";

export default defineConfig({
  output: "server",
  adapter: deno(),
});

3. Next, update your deno.json (or package.json)

// deno.json
{
  "tasks": {
    "dev": "deno run -A npm:astro dev",
    "build": "deno run -A npm:astro build",
    "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs",
  },
}

// package.json
{
  "scripts": {
    "dev": "deno run -A npm:astro dev",
    "build": "deno run -A npm:astro build",
    "preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs",
  },
}

4. You can now preview your production Astro site locally with Deno

deno task build 
deno task preview

Usage

After performing a build there will be a dist/server/entry.mjs module. You can start a server by importing this module in your Deno app:

import "./dist/server/entry.mjs";

See the start option below for how you can have more control over starting the Astro server.

You can also run the script directly using deno:

deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs

Configuration

To configure this adapter, pass an object to the deno() function call in astro.config.mjs.

// astro.config.mjs
import { defineConfig } from "astro/config";
import deno from "@deno/astro-adapter";

export default defineConfig({
  output: "server",
  adapter: deno({
    //options go here
  }),
});

start

This adapter automatically starts a server when it is imported. You can turn this off with the start option:

import { defineConfig } from "astro/config";
import deno from "@deno/astro-adapter";

export default defineConfig({
  output: "server",
  adapter: deno({
    start: false,
  }),
});

If you disable this, you need to write your own Deno web server. Import and call handle from the generated entry script to render requests:

import { handle } from "./dist/server/entry.mjs";

Deno.serve((req: Request) => {
  // Check the request, maybe do static file handling here.

  return handle(req);
});

port and hostname

You can set the port (default: 8085) and hostname (default: 0.0.0.0) for the deno server to use. If start is false, this has no effect; your own server must configure the port and hostname.

import { defineConfig } from "astro/config";
import deno from "@deno/astro-adapter";

export default defineConfig({
  output: "server",
  adapter: deno({
    port: 8081,
    hostname: "myhost",
  }),
});

Examples

The Deno + Astro Template includes a preview command that runs the entry script directly. Run npm run build then npm run preview to run the production deno server.

Contributing

To configure your development environment, clone the repository and install dependencies.

git clone
cd astro-adapter
deno i

The Deno Astro Adapter is currently built and tested with Deno 2.x. To test your changes make sure you have Deno 2.x installed

deno task test

Finally, you can check your code formatting with

deno fmt

This package is maintained by Deno's Core team. You're welcome to submit an issue or PR!

版本与发布记录

@deno/astro-adapter 共发布 15 个版本,首次发布于 2024/04/25;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.0latest2026/07/024 个月前
0.5.22026/05/295 个月前
0.5.12026/05/056 个月前
0.4.02026/04/097 个月前
0.3.22025/09/221.1 年前
0.3.12025/05/231.5 年前

关于 @deno/astro-adapter 的常见问题

@deno/astro-adapter 是什么?

Deploy your Astro site to a Deno server

如何安装 @deno/astro-adapter?

在项目目录运行 npm install @deno/astro-adapter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:astro(^7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@deno/astro-adapter 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/deno__astro-adapter 是否存在。

@deno/astro-adapter 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@deno/astro-adapter 可以商用吗?

@deno/astro-adapter 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@deno/astro-adapter 的下载量有多少?

根据 npm 官方下载统计,@deno/astro-adapter 在 2026/10/12 – 2026/11/10 这 30 天内被下载 16,556 次,日均约 552 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deno/astro-adapter 还在维护吗?

最新版本 0.6.0 发布于 2026/07/02(4 个月前);至今共发布 15 个版本,其中过去 12 个月发布了 4 个;首次发布于 2024/04/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。