Server-Sent Events in Hono

From the Hono cheat sheet · Streaming & SSE · verified Jul 2026

Server-Sent Events

Stream real-time updates to clients

typescript
import { streamSSE } from 'hono/streaming'

let eventId = 0

app.get('/sse', async (c) => {
  return streamSSE(c, async (stream) => {
    while (true) {
      await stream.writeSSE({
        data: JSON.stringify({ time: new Date().toISOString() }),
        event: 'time-update',
        id: String(eventId++),
      })
      await stream.sleep(1000)
    }
  })
})

// Client-side
const eventSource = new EventSource('/sse')
eventSource.addEventListener('time-update', (e) => {
  console.log(JSON.parse(e.data))
})
💡 streamSSE automatically sets correct SSE headers
⚡ Use stream.sleep(ms) for intervals, not setTimeout
📌 stream.onAbort() handles client disconnection
🎯 Client uses EventSource API for SSE

More Hono tasks

Back to the full Hono cheat sheet