# UpgradeWebSocket

**Kind:** Interface

**Source:** [`src/helper/websocket/index.ts`](https://github.com/honojs/hono/blob/main/src/helper/websocket/index.ts#L24)

**Part of:** [Helper](subsystem-src-helper)

Upgrade WebSocket Type

`UpgradeWebSocket` names the contract used by the WebSocket helper when an HTTP request is upgraded to a WebSocket connection. Code can accept or pass this interface without depending on a concrete upgrade implementation.

## Diagram

```mermaid
graph LR
  Request[HTTP Request] --> Upgrade[UpgradeWebSocket]
  Upgrade --> Connection[WebSocket Connection]
  Connection --> Handler[Application Handler]
```

## Usage

```ts
import type { UpgradeWebSocket } from './helper/websocket'

function registerUpgrade(
  upgrade: UpgradeWebSocket,
): UpgradeWebSocket {
  return upgrade
}

declare const platformUpgrade: UpgradeWebSocket

const upgrade = registerUpgrade(platformUpgrade)
```

## AI Coding Instructions

- Import `UpgradeWebSocket` with `import type` when it is only used for type checking.
- Pass implementations through this interface instead of depending on platform-specific upgrade objects.
- Do not assume members or behavior that are not declared by the interface.
- Keep HTTP-to-WebSocket upgrade handling near the WebSocket helper integration.
