meshql-sse (@meshql/sse)
Field-aware MeshQL subscriptions over Server-Sent Events (v0.9.0 — 0.2.1 adds Fastify and Hono adapters).
Install
Section titled “Install”npm install meshql-sse meshql-pubsub meshql-core meshql-http# ornpx jsr add @meshql/sse @meshql/pubsub @meshql/core @meshql/httpPublished on npm as meshql-sse and JSR as @meshql/sse.
How it works
Section titled “How it works”Clients open GET /mesh/:entity/:id/events with the same X-Mesh-Query headers as a point read. When @meshql/pubsub notifies a change, the server re-runs the selection and streams an update SSE event with fresh JSON.
Express
Section titled “Express”import express from "express";import { createMesh } from "@meshql/core";import { meshExpressRouter } from "@meshql/http/express";import { InMemoryPubSubStore, notifyEntityUpdate } from "@meshql/pubsub";import { meshSseExpressRouter } from "@meshql/sse/express";
const pubsub = new InMemoryPubSubStore();const mesh = createMesh(schema);
const app = express();app.use(meshExpressRouter(mesh, "/mesh"));app.use(meshSseExpressRouter(mesh, { pubsub }, "/mesh"));
// After a mutation, notify subscribers:notifyEntityUpdate(pubsub, "post", postId);Fastify
Section titled “Fastify”import Fastify from "fastify";import { createMeshSseFastifyPlugin } from "@meshql/sse/fastify";
const app = Fastify();await app.register(createMeshSseFastifyPlugin(mesh, { pubsub, basePath: "/mesh" }));import { Hono } from "hono";import { meshSseHonoRoutes } from "@meshql/sse/hono";
const app = new Hono();app.route("/", meshSseHonoRoutes(mesh, { pubsub, basePath: "/mesh" }));Signed requests (integrity/access plugins) use the same headers as GET — access control runs on each SSE refresh.
vs GraphQL subscriptions
Section titled “vs GraphQL subscriptions”GraphQL uses a persistent websocket with subscription resolvers. MeshQL SSE is REST-native: same selection as GET, refresh on pub/sub events. See From GraphQL.
Related
Section titled “Related”- Thinking in MeshQL — mental model for selection + transport
- HTTP adapters