1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { Hono } from "jsr:@hono/hono";
import { stream, streamSSE, streamText } from "jsr:@hono/hono/streaming";
const app = new Hono();
app.get("/", (c) => {
return streamText(c, async (stream) => {
// Write a text with a new line ('\n').
await stream.writeln("Hello");
// Wait 1 second.
await stream.sleep(1000);
// Write a text without a new line.
await stream.write(`Hono!`);
});
});
export default app.fetch;