{"id":17361742,"url":"https://github.com/lukas-reining/eventsource","last_synced_at":"2026-04-02T15:58:22.152Z","repository":{"id":206025930,"uuid":"715645105","full_name":"lukas-reining/eventsource","owner":"lukas-reining","description":"EventSource implementation that is fully compliant with the WHATWG Server-Sent Events specification but takes more arguments.","archived":false,"fork":false,"pushed_at":"2025-01-03T23:44:56.000Z","size":392,"stargazers_count":57,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T18:07:12.090Z","etag":null,"topics":["eventsource","server-sent-events","sse"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukas-reining.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-11-07T14:52:02.000Z","updated_at":"2025-03-13T01:04:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c6e64b8-9ba2-4d1b-bd28-fea1776b449d","html_url":"https://github.com/lukas-reining/eventsource","commit_stats":null,"previous_names":["lukas-reining/eventsource"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas-reining%2Feventsource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas-reining%2Feventsource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas-reining%2Feventsource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukas-reining%2Feventsource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukas-reining","download_url":"https://codeload.github.com/lukas-reining/eventsource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234920,"owners_count":20905854,"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","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":["eventsource","server-sent-events","sse"],"created_at":"2024-10-15T19:34:56.568Z","updated_at":"2026-04-02T15:58:22.109Z","avatar_url":"https://github.com/lukas-reining.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EventSource\n\n[![https://www.npmjs.com/package/extended-eventsource](https://img.shields.io/npm/v/extended-eventsource?logo=npm)](https://www.npmjs.com/package/extended-eventsource)\n[![https://www.npmjs.com/package/extended-eventsource](https://img.shields.io/npm/dm/extended-eventsource?logo=npm)](https://www.npmjs.com/package/extended-eventsource)\n![NPM](https://img.shields.io/npm/l/extended-eventsource)\n\nThis is a custom EventSource implementation that is fully compliant with\nthe [WHATWG Server-Sent Events specification](https://html.spec.whatwg.org/multipage/server-sent-events.html) but takes\nmore arguments like request headers.\n\nIt can be used in both web and Node.js environments.\n\nThe motivation for this library is that the native browser EventSource does not offer options for changing the request\nthat is sent to the server.\nThis means that e.g. you can not send an authorization header. This is fixed by this library.\n\n## Features\n\n- Supports both web and Node.js environments\n- Follows the WHATWG Server-Sent Events specification and can be uses everywhere where the native EventSource would be\n  used.\n\n## Installation\n\nInstall the package using npm:\n\n```bash\nnpm i extended-eventsource\n```\n\n## Usage\n\nThe package exposes a single class called `EventSource`.\nTo use it, create a new instance of `EventSource` with the URL of the server-sent events endpoint, and an optional\nconfiguration object.\n\n### Web\n\n```typescript\nimport { EventSource } from 'extended-eventsource';\n\nconst eventSource = new EventSource('/events', {\n  headers: {\n    Authorization: 'Bearer token',\n  },\n  retry: 3000,\n});\n\neventSource.onopen = () =\u003e {\n  console.log('Connection opened');\n};\n\neventSource.onmessage = (event: MessageEvent) =\u003e {\n  console.log('Message received:', event.data);\n};\n\neventSource.onerror = (error) =\u003e {\n  console.error('Error occurred:', error);\n};\n\n\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to open issues or submit pull requests.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas-reining%2Feventsource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukas-reining%2Feventsource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukas-reining%2Feventsource/lists"}