ParentProvider
TheParentProvider 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 callsbalance(number | null): Current WIN token balance in weishowWinModal(wins: string): Show win modalshowLossModal(loss: string): Show loss modalshowToast(options): Show toast notificationshowCustomModal(content): Show custom modalrefetchBalance(): Request balance refresh from platform
useBalance()
Get player balance (number | null)useToken()
Get authentication token (string | null)useRefetchBalance()
Function to request balance refreshuseCustomModal()
Function to show custom modalsuseAuthenticatedFetch()
Fetch function with automatic Bearer token headerMaking API Calls
Use theuseAuthenticatedFetch() hook to make authenticated requests:
- Automatically includes
Authorization: Bearer {token}header - Sets
Content-Type: application/jsonby default - Merges additional headers you provide
- Handles token from
useToken()automatically
HypeDuel