⚠️
Important! We’ve moved to V3! This documentation is for V2 only and will be updated in May.
Developer Hub
🔮 For applications
SDK
Data Hooks
useGame

useGame

The useGame hook is used for fetch specific game data.

ℹ️

Hook represents a logic wrapper over TanStack Query's useQuery hook. Explore TanStack Query docs (opens in a new tab) to understand what data the hook returns.

Usage

import { useGame } from '@azuro-org/sdk'
 
const { data, isFetching, error } = useGame(props)
ℹ️

The useGame hook automatically fetches a live game and returns it, otherwise, it returns the pre-match game.

Props

{
  gameId: string | bigint
  query?: QueryParameter<GameQuery['game']> // useQuery params
}
⚠️

gameId property is not the same as id. Each game fetched using useGames hook contains the gameId:

import { useGame } from '@azuro-org/sdk'
 
const { data: games } = useGames()
 
const gameId = games?.[0]?.gameId
 
const { data } = useGame({ gameId })

Return Value

UseQueryResult<GameQuery['game']>
import { type UseQueryResult } from '@tanstack/react-query'
 
type GameQuery = {
    __typename?: 'Query'
    game?: {
        __typename?: 'Game'
        id: string
        gameId: string
        slug: string
        title: string
        startsAt: string
        state: Types.GameState
        turnover: string
        sport: {
            __typename?: 'Sport'
            sportId: string
            slug: string
            name: string
            sporthub: {
                __typename?: 'SportHub'
                id: string
                slug: string
            }
        }
        league: {
            __typename?: 'League'
            slug: string
            name: string
        }
        country: {
            __typename?: 'Country'
            slug: string
            name: string
        }
        participants: Array<{
            __typename?: 'Participant'
            image?: string | null
            name: string
        }>
    } | null
}