{"repo":"alexanderkasten/use-next-sse","free":true,"listed":false,"github":"https://github.com/alexanderkasten/use-next-sse","clone":"git clone https://github.com/alexanderkasten/use-next-sse.git","description":"use-next-sse is a lightweight and easy-to-use React hook library for implementing Server-Sent Events (SSE) in Next.js applications, enabling real-time, unidirectional data streaming from server to client.","language":"TypeScript","stars":16,"topics":["data","events","nextjs","react","server-sent-events","serverless","sse","streaming","eventsource","real-time"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"use-next-sse use-next-sse is a lightweight and easy-to-use React hook library for implementing Server-Sent Events (SSE) in Next.js applications, enabling real-time, unidirectional data streaming from server to client. Installation Quick Start Server-Side (Next.js API Route) Create a new file app/api/sse/route.ts with the following content: Client-Side (React Component) Create a new file app/components/Counter.tsx with the following content: Usage in a Page Use the Counter component in a page, for example in app/page.tsx : This example demonstrates a simple counter that updates every second using Server-Sent Events. The server sends updates for 10 seconds before closing the connection. API Reference Client-Side API useSSE (options: SSEOptions): SSEResult A React hook to manage Server-Sent Events (SSE) connections in your Next.js application. Type Parameters: - T - The type of the data expected from the SSE connection. Defaults to any . Parameters: The hook accepts a single options object with the following properties: Property Type Required Default Description ---------- ------ ---------- --------- ------------- url string Yes - The URL endpoint to connect to for SSE. Must be a valid URL path. eventName string No 'message' The name of the event to listen for. Use custom event names to handle different event types from your SSE endpoint. reconnect boolean \\ { interval?: number, maxAttempts?: number } No false Controls automatic reconnection behavior. Can be a boolean or an obje","default_branch":null,"files":null,"tree":[],"storefront":"/r/alexanderkasten","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/alexanderkasten/use-next-sse/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}