/Knowledge/sources/honojs__hono/llms-full/websocket-helper-examples-server-and-client--a8682a7f076e.md
WebSocket Helper: Examples > Server and Client - hono-docs
WebSocket Helper: Examples Server and Client Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt server an...
WebSocket Helper: Examples > Server and Client
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#server-and-client
Summary
## Content
```ts
// server.ts
import { Hono } from 'hono'
import { upgradeWebSocket } from 'hono/cloudflare-workers'
const app = new Hono().get(
'/ws',
upgradeWebSocket(() => {
return {
onMessage: (event) => {
console.log(event.data)
},
}
})
)
export default app
// client.ts
import { hc } from 'hono/client'
import type app from './server'
const client = hc<typeof app>('http://localhost:8787')
const ws = client.ws.$ws(0)
ws.addEventListener('open', () => {
setInterval(() => {
ws.send(new Date().toString())
}, 1000)
})
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#server-and-client",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / WebSocket Helper > Examples > Server and Client",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 711,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "WebSocket Helper: Examples > Server and Client",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}