useLiveMatches
Subscribes to matches over WebSocket, filtered by sports/regions/competitions. Updates in place as matches start, finish, or change.
Wraps matches.subscribeLive(). Pushes match.upd/match.del events in
place as matches start, finish, or their score/clock changes, for as long
as the component stays mounted. Unlike
useMatches, always reflects the
current live roster rather than a one-shot snapshot: the right choice
when you need real clocks/scores on a list, not just which matches exist.
Installation
pnpm dlx shadcn@latest add https://mrdoge.co/r/use-live-matches.jsonAlso requires MRDOGE_ODDS_API_KEY. Set it in your own environment after installing.
Installing this pulls in two files: the hook itself (a thin re-export
from @mrdoge/react, which does the
real work) and a Next.js route at app/api/mrdoge/token/route.ts that
mints short-lived tokens using @mrdoge/node and your own
MRDOGE_ODDS_API_KEY. The browser client never sees the raw key.
Usage
import { useLiveMatches } from "@/hooks/use-live-matches"
const matches = useLiveMatches({ sports: ["soccer"], regionIds: [1] })Takes a single options object, like every real SDK method it wraps
(matches.subscribeLive(params)), not positional arguments.
Parameters
Prop
Type
Returns
Match[] | null | undefined: undefined while loading, null if the
subscribe failed (no fallback data; an honest empty state beats a fake
one), otherwise the current live roster, updated in place as
match.upd/match.del events arrive.