# 策展 · X (Twitter) 🔥🔥🔥🔥

> 📖 本站完整內容索引（documentation index）：[llms.txt](/llms.txt)

> 作者：Vercel Developers (@vercel_dev) · 平台：X (Twitter) · 日期：2026-06-23

> 原始來源：https://x.com/vercel_dev/status/2069108513423454298

## 中文摘要

Vercel 平台正式支援 WebSockets，讓開發者能透過標準 Node.js 函式庫建構即時互動應用。

**核心功能更新**
Vercel 於 2026 年 6 月 22 日宣布其 Functions 正式進入 WebSockets 公開測試階段，這項更新允許使用者在 Vercel 上建立雙向通訊機制。開發者現在可以運用標準的 Node.js 函式庫（如 `ws`）或高階框架（如 `socket.io`）來開發需要即時互動的應用程式，例如 AI 串流、聊天室或協作工具。

**技術架構與計費**
此功能整合於 Vercel 的 Fluid compute 架構中，並遵循與一般 Function 呼叫相同的限制與定價規則。在計費方面，Vercel 採用 Active CPU 定價模式，這意味著系統僅會針對 Function 處理訊息的實際運作時間進行收費，不會針對閒置的連線時間計費。

**實作範例**
開發者無需額外設定，即可直接在專案中部署 WebSocket 伺服器。以下為使用 `express` 與 `ws` 函式庫的範例程式碼：

`api/ws.ts`
```ts
import express from 'express';
import { createServer } from 'http';
import { WebSocketServer } from 'ws';

const app = express();
const server = createServer(app);
const wss = new WebSocketServer({ server });

wss.on('connection', (ws) => {
  ws.on('message', (data) => {
    ws.send(data);
  });
});

export default server;
```

欲深入了解詳細規格與部署方式，可參考 [Vercel 官方文件](https://vercel.com/changelog/websocket-support-is-now-in-public-beta) 以獲取更多資訊。

## 標籤

功能更新, Web, Vercel
