Use Data Table Stream Route
GitHubConnects a data table to a server-sent events route and caches the latest snapshot.
Installation
bash
pnpm dlx shadcn@latest add @cs/use-data-table-stream-routeUsage
tsx
import { useDataTableStreamRoute } from "@/hooks/cs/use-data-table-stream-route"tsx
const stream = useDataTableStreamRoute<Row>("/api/orders/stream", fetchData)API Reference
UseDataTableStreamRouteReturn
tsx
type UseDataTableStreamRouteReturn = ReturnType<typeof useDataTableStreamRoute<TData>>useDataTableStreamRoute
Connects a data table to a server-sent events route and caches the latest snapshot. The stream can be paused while menus or dialogs are open without losing the latest update.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| route * | string | null | - | - |
| params * | DataTableOnData | - | - |
Returns: unknown