GraphQL subscriptions over plain HTTP
Zero-dependency, HTTP/1 safe, simple, spec compliant server and client. graphql-sse is the reference implementation of the GraphQL over Server-Sent Events protocol, and runs wherever a request handler does. Part of the Hive ecosystem by The Guild.
- Spec compliant, as the reference implementation
- Single and distinct connection modes
- Server and client in one small library
Streaming results, no WebSocket required
- Spec compliantFully compliant with the GraphQL over SSE protocol: a single connection mode that is safe for HTTP/1 servers and subscription-heavy apps, a distinct connection mode where each connection is its own subscription, and improvements over plain SSE for clarity and stability.
- Server and clientOne zero-dependency library ships both sides. Tree-shaking and module separation keep the bundle small, and smart retry strategies let you shape reconnection to your needs.
- Run everywhereThe handler is completely server agnostic, with ready-made adapters for http, http2, express, fastify, koa and the fetch API, so it runs in Node, Bun, Deno and edge runtimes alike.
Subscribe in a few lines
Mount the handler on any HTTP server, then iterate over subscription events on the client with an async iterator; queries and mutations go through the same client.
Get startedimport { createClient } from 'graphql-sse';
const client = createClient({
url: 'http://localhost:4000/graphql/stream',
});
const subscription = client.iterate({
query: 'subscription { greetings }',
});
for await (const event of subscription) {
console.log(event.data); // { greetings: 'Hi' }, { greetings: 'Bonjour' }, ...
}Learn more
Recipes
Short and concise code snippets for common use cases: EventSource, Relay, urql, Apollo, auth, dynamic schemas, persisted queries and more.
Browse the recipes →API reference
Every module, function, class and interface of the client, the handler, the protocol messages and the server adapters.
API reference →Changelog
Every release and the changes it brought.
Changelog →
Discover the complete ecosystem of tools and libraries
Complete GraphQL Federation Stack
Our libraries to support all your GraphQL needs
Explore the Ecosystem