Developer Hub
🔮 For applications
SDK
Data Hooks
useGame

Hook is used for fetch specific game data.

Hook represents a logic wrapper over standard Apollo's useQuery hook. Explore Apollo's docs (opens in a new tab) to understand what data the hooks return.

Usage

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

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

Props

{
  gameId: string | bigint
}
⚠️

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

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

Return Value

{ 
  loading: boolean
  error: Error | null
  isGameInLive: boolean // true if the game exists in the live.
  game: { 
    id: string
    gameId: number
    title?: string | null
    startsAt: number
    status: GraphGameStatus
    sport: { 
      sportId: string
      slug: string
      name: string 
    }
    league: {
      slug: string
      name: string
      country: { 
        slug: string
        name: string 
      } 
    }
    participants: Array<{ 
      image?: string | null
      name: string 
    }>
  } 
}
 
enum GraphGameStatus {
  Canceled = 'Canceled',
  Created = 'Created',
  Paused = 'Paused',
  Resolved = 'Resolved'
}