Overview
ofetch supports Server-Sent Events (SSE) through thestream response type, allowing you to consume real-time event streams from your server.
Basic Usage
How It Works
Fromsrc/fetch.ts:224-227:
responseType: 'stream' is set:
- ofetch skips automatic parsing
- Returns the raw
ReadableStreamfromresponse.body - Allows manual chunk processing
Response Types
Fromsrc/types.ts:123-135:
responseType: 'stream' returns a ReadableStream<Uint8Array>.
SSE Example from README
FromREADME.md:294-307:
Common Use Cases
Real-Time Notifications
Chat Messages
Progress Updates
Parsing SSE Format
Cancelling Streams
With Custom Instances
TypeScript Support
Detection of Response Type
Fromsrc/fetch.ts:208-213:
Content-Type: text/event-stream header on your server, though explicit responseType: 'stream' is recommended for SSE.