orpc-event-iterator-sse
Streaming responses, real-time updates, and server-sent events using oRPC.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Streaming responses, real-time updates, and server-sent events using oRPC.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Quick reference for Better Notify configuration, patterns, and common gotchas
Interactive setup wizard for adding Better Notify to a TypeScript/JavaScript project
Context and API guidance for Better Notify — end-to-end typed notification infrastructure for Node.js
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.
Use oRPC inside an Astro project.
Functions to encode and decode base64url strings (URL-safe variant of base64).
| name | oRPC Event Iterator (SSE) |
| description | Streaming responses, real-time updates, and server-sent events using oRPC. |
| license | MIT |
| metadata | {"author":"Ali Torki","homepage":"https://github.com/ali-master","version":"1.0.0"} |
oRPC provides built-in support for streaming responses, real-time updates, and server-sent events (SSE) without any extra configuration.
const example = os
.handler(async function* ({ input, lastEventId }) {
while (true) {
yield { message: 'Hello, world!' }
await new Promise(resolve => setTimeout(resolve, 1000))
}
})
import { eventIterator } from '@orpc/server'
const example = os
.output(eventIterator(z.object({ message: z.string() })))
.handler(async function* ({ input, lastEventId }) {
while (true) {
yield { message: 'Hello, world!' }
await new Promise(resolve => setTimeout(resolve, 1000))
}
})
Using withEventMeta, attach metadata (event ID, retry interval) to events:
import { withEventMeta } from '@orpc/server'
const example = os
.handler(async function* ({ input, lastEventId }) {
if (lastEventId) {
// Resume streaming from lastEventId
} else {
while (true) {
yield withEventMeta({ message: 'Hello, world!' }, { id: 'some-id', retry: 10_000 })
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
})
Use return to signal end of stream:
const example = os
.handler(async function* ({ input, lastEventId }) {
while (true) {
if (done) return
yield { message: 'Hello, world!' }
await new Promise(resolve => setTimeout(resolve, 1000))
}
})
const example = os
.handler(async function* ({ input, lastEventId }) {
try {
while (true) {
yield { message: 'Hello, world!' }
await new Promise(resolve => setTimeout(resolve, 1000))
}
} finally {
console.log('Cleanup logic here')
}
})
Build real-time features like chat with resume support:
const publisher = new MemoryPublisher<{
'something-updated': { id: string }
}>()
const live = os
.handler(async function* ({ input, signal }) {
const iterator = publisher.subscribe('something-updated', { signal })
for await (const payload of iterator) {
yield payload
}
})
const publish = os
.input(z.object({ id: z.string() }))
.handler(async ({ input }) => {
await publisher.publish('something-updated', { id: input.id })
})
Lightweight synchronous publisher (no resume support):
import { EventPublisher } from '@orpc/server'
const publisher = new EventPublisher<{
'something-updated': { id: string }
}>()
const livePlanet = os
.handler(async function* ({ input, signal }) {
for await (const payload of publisher.subscribe('something-updated', { signal })) {
// handle payload here
}
})
const update = os
.input(z.object({ id: z.string() }))
.handler(({ input }) => {
publisher.publish('something-updated', { id: input.id })
})