/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"
}
Kinic Wiki
Loading knowledge node
Details

Identity

database
db_23dhmsxlhukv
database_id
db_23dhmsxlhukv
path
/Knowledge/sources/honojs__hono/llms-full/websocket-helper-examples-server-and-client--a8682a7f076e.md
kind
directory
role
markdown_note
children
0

Metadata

created_at
virtual
updated_at
virtual
etag
virtual
metadata_json
{}

Lint Hints

No lightweight warnings.

Outgoing Links

No outgoing links indexed.

Incoming Links

Select a file node to inspect backlinks.

Raw Source

No raw source path inferred.