@edgeone/vite

中文文档
2.0.1发布于 2026/04/17MITTypeScriptES Module近 30 天下载 5467

EdgeOne universal Vite adapter — supports Vite SSR, Vike, and TanStack Start

原始使用文档
文档目录11 节
  1. Installation
  2. Quick Start
  3. TanStack Start
  4. Vike
  5. Standard Vite SSR
  6. API
  7. edgeoneAdapter(options?)
  8. Options
  9. How It Works
  10. Build Output
  11. License

@edgeone/vite

Vite plugin adapter for deploying SSR applications to EdgeOne Pages. Built on @universal-deploy/store, with out-of-the-box support for Vite SSR, TanStack Start, and Vike.

Installation

Note: This package is currently in beta. Install with the beta tag:

npm install @edgeone/vite@beta

Peer dependency: Vite 7 or 8.

Quick Start

TanStack Start

// vite.config.ts
import { defineConfig } from "vite";
import { tanstackStart } from "@tanstack/react-start/plugin";
import { edgeoneAdapter } from "@edgeone/vite";

export default defineConfig({
  plugins: [tanstackStart(), edgeoneAdapter()],
});

Vike

Requires Vike ≥ 0.4.257. Add server: true to your Vike config to enable Vike's built-in Universal Deploy integration:

// pages/+config.ts
export default {
  server: true,
}
// vite.config.ts
import { defineConfig } from "vite";
import vike from "vike/plugin";
import { edgeoneAdapter } from "@edgeone/vite";

export default defineConfig({
  plugins: [vike(), edgeoneAdapter()],
});

Standard Vite SSR

// vite.config.ts
import { defineConfig } from "vite";
import { edgeoneAdapter } from "@edgeone/vite";

export default defineConfig({
  build: { ssr: "src/entry-server.ts" },
  plugins: [edgeoneAdapter()],
});

SSR entry requirement: The entry file must default-export a { fetch(request: Request): Response | Promise<Response> } interface.

API

edgeoneAdapter(options?)

Universal adapter for any framework that registers a Fetchable entry in the Universal Deploy store.

Options

OptionTypeDefaultDescription
outputDirstring".edgeone"Output directory for deployment artifacts
verbosebooleanfalseEnable verbose logging during build

How It Works

The adapter is composed of 6 Vite plugins:

PluginSourcePurpose
edgeone:bundle-depsAdapterForce-bundle all npm deps (EdgeOne has no node_modules)
compat@universal-deploy/storeAuto-discover SSR entries from rollupOptions.input
catchAll@universal-deploy/storeGenerate a catch-all virtual module aggregating all registered entries
resolver@universal-deploy/storeResolve store virtual module IDs
edgeone:apply-catch-allAdapterAppend the catch-all entry to the SSR build input
edgeone:outputAdapterGenerate EdgeOne deployment artifacts after build
edgeone:ssr-entryAdapterAuto-trigger SSR build after client build (when ssrEntry is set)

The adapter is completely framework-agnostic — it reads entries from the Universal Deploy store and produces EdgeOne deployment artifacts. Frameworks (Vike, TanStack Start, etc.) are responsible for registering their own Fetchable entries in the store.

After the build completes, the edgeone:output plugin:

  1. Copies SSR build output into <outputDir>/cloud-functions/ssr-node/
  2. Generates a bridge entry (handler.js) that converts Node.js IncomingMessage to Web Request (compatible with EdgeOne Pages bootstrap)
  3. Copies static assets into <outputDir>/assets/
  4. Generates config.json with route definitions from store-registered entries

Build Output

.edgeone/
├── assets/                  # Client-side static assets
└── cloud-functions/
    └── ssr-node/
        ├── handler.js       # Bridge entry (adapter-generated, IncomingMessage → Request)
        ├── _handler.js      # Catch-all handler (Vite build output)
        ├── server.js        # Framework SSR entry
        ├── assets/          # Server-side chunks
        └── config.json      # EdgeOne Pages route config

License

MIT

版本与发布记录

@edgeone/vite 共发布 16 个版本,首次发布于 2026/01/28;过去 12 个月发布了 16 个版本。

版本发布日期距今
2.0.1latest2026/04/176 个月前
2.0.0-beta.2beta2026/04/176 个月前
2.0.02026/04/137 个月前
2.0.0-beta.12026/04/137 个月前
1.1.02026/03/187 个月前
2.0.0-beta.02026/03/138 个月前

关于 @edgeone/vite 的常见问题

@edgeone/vite 是什么?

EdgeOne universal Vite adapter — supports Vite SSR, Vike, and TanStack Start

如何安装 @edgeone/vite?

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

@edgeone/vite 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@edgeone/vite 支持 ESM 还是 CommonJS?

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

@edgeone/vite 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@edgeone/vite 可以商用吗?

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

@edgeone/vite 的下载量有多少?

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

@edgeone/vite 还在维护吗?

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