Skip to main content

ParentProvider

The ParentProvider component connects your game frontend to the Upside platform and provides authentication.

Available Hooks

useParent()

Access full context (token, balance, showWinModal, showLossModal, etc.) Return Values:
  • token (string | null): JWT authentication token for backend calls
  • balance (number | null): Current WIN token balance in wei
  • showWinModal(wins: string): Show win modal
  • showLossModal(loss: string): Show loss modal
  • showToast(options): Show toast notification
  • showCustomModal(content): Show custom modal
  • refetchBalance(): Request balance refresh from platform

useBalance()

Get player balance (number | null)

useToken()

Get authentication token (string | null)

useRefetchBalance()

Function to request balance refresh

useCustomModal()

Function to show custom modals

useAuthenticatedFetch()

Fetch function with automatic Bearer token header

Making API Calls

Use the useAuthenticatedFetch() hook to make authenticated requests:
How useAuthenticatedFetch() Works:
  • Automatically includes Authorization: Bearer {token} header
  • Sets Content-Type: application/json by default
  • Merges additional headers you provide
  • Handles token from useToken() automatically

Frontend Example