{"id":19300474,"url":"https://github.com/rubriclab/events","last_synced_at":"2025-09-02T01:33:49.768Z","repository":{"id":258413479,"uuid":"873807071","full_name":"RubricLab/events","owner":"RubricLab","description":"Events architecture","archived":false,"fork":false,"pushed_at":"2025-07-01T18:07:44.000Z","size":59,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-01T18:34:43.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubricLab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-16T18:48:46.000Z","updated_at":"2025-07-01T18:07:48.000Z","dependencies_parsed_at":"2024-10-18T22:27:04.273Z","dependency_job_id":"b67339f6-70ae-4621-8691-9aa8a041d0c1","html_url":"https://github.com/RubricLab/events","commit_stats":null,"previous_names":["rubriclab/events"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubricLab/events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubricLab%2Fevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubricLab%2Fevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubricLab%2Fevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubricLab%2Fevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubricLab","download_url":"https://codeload.github.com/RubricLab/events/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubricLab%2Fevents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273218425,"owners_count":25065913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:14:52.334Z","updated_at":"2025-09-02T01:33:49.755Z","avatar_url":"https://github.com/RubricLab.png","language":"TypeScript","readme":"# @rubriclab/events\n\nThis Events package gives you a type-safe, Redis-backed pub/sub layer that streams events from your server to the browser over Server-Sent Events (SSE).\n\nIt is part of Rubric's architecture for Generative UI when used with:\n- [@rubriclab/actions](https://github.com/rubriclab/actions)\n- [@rubriclab/blocks](https://github.com/rubriclab/blocks)\n- [@rubriclab/chains](https://github.com/rubriclab/chains)\n- [@rubriclab/agents](https://github.com/rubriclab/agents)\n\n[Demo](https://chat.rubric.sh)\n\n## Get Started\n### Installation\n`bun add @rubriclab/events`\n\n\u003e @rubriclab scope packages are not built, they are all raw typescript. If using in a next.js app, make sure to transpile.\n\n```ts\n// next.config.ts\nimport type { NextConfig } from  'next' \nexport default {\n\ttranspilePackages: ['@rubriclab/events'],\n\treactStrictMode: true\n} satisfies  NextConfig\n```\n\n\u003e If using inside the monorepo (@rubric), simply add `{\"@rubriclab/events\": \"*\"}` to dependencies and then run `bun i`\n\n\n### Define Event types\n\n```ts\nexport const eventTypes = createEventTypes({\n  ping: z.literal('ping'),\n})\n```\n\n### Create the events server and a route\n```ts\nimport { createEventsServer } from '@rubriclab/events/server'\nimport env from '~/env'\nimport { eventTypes } from './types'\n\nexport const { publish, GET, maxDuration } = createEventsServer({\n\teventTypes,\n\tredisURL: env.UPSTASH_REDIS_URL\n})\n```\n\n```ts\n// app/api/events/route.ts\nexport { GET, maxDuration } from './server'\n```\n\n### Create the events client\n\n```ts\nimport { createEventsClient } from '@rubriclab/events/client'\nimport { eventTypes } from './types'\n\nexport const { useEvents } = createEventsClient({\n\turl: '/api/events', // The url of the server\n\teventTypes\n})\n```\n\n### Publish an event from the server\n```ts\nawait publish({\n  channel: '123',\n  eventType: 'ping',\n  payload: 'ping'\n})\n```\n\n\n### Consume it on the client!\n```ts\nuseEvents({\n\t\tid: '123',\n\t\ton: {\n\t\t\tping: (payload) =\u003e {\n\t\t\t\tconsole.log('ping', payload)\n\t\t\t}\n\t\t}\n\t})\n```\n\nCommits to main will automatically publish a new version to npm.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubriclab%2Fevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubriclab%2Fevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubriclab%2Fevents/lists"}