useOdds
Subscribes to a single match's odds over WebSocket (Business tier). Pre-live or in-play, every matching market updates in place as odds change.
Wraps odds.subscribe(). One subscription covers both pre-live and
in-play odds: whichever markets are currently posted for the match.
Business tier only. On a lower tier the subscribe call rejects and this
resolves to null, with no fallback. Pairs with
useLiveMatch, which subscribes
to the match itself.
Installation
pnpm dlx shadcn@latest add https://mrdoge.co/r/use-odds.jsonAlso requires MRDOGE_ODDS_API_KEY. Set it in your own environment after installing.
Same supporting file as useLiveMatch
(the token route) and the same @mrdoge/react
dependency; if you've already installed that hook, you're set.
Usage
import { useOdds } from "@/hooks/use-odds"
const markets = useOdds({ matchId, betTypes: ["SOCCER_MATCH_RESULT"] })Takes a single options object, like every real SDK method it wraps
(odds.subscribe(params)), not positional arguments.
Parameters
Prop
Type
Returns
Market[] | null | undefined: undefined while loading or when matchId
is undefined, null once loaded if no markets matched (wrong tier, or
none posted right now), otherwise every matching market, updated in place
as odds.upd events arrive.