React Native SDK (Tournaments)

Headless Demographic Form usage examples for the ReactNative SDK

Overview

The Pool Tournament feature allows end users to join pre-created tournaments and earn rewards based on their ranking at the end of the matchup.

The outcome and payout structure of each pool must be provided to Lucra using these API endpoints.

This React Native wrapper exposes the tournament functionality from the underlying Android and iOS native SDKs.

Methods

getRecomendedTournaments

Retrieve a list of recommended tournaments.

Parameters:

  • includeClosed: Should completed tournaments be included in the query.

  • limit: The max number tournaments that will be returned.

Returns: Promise<PoolTournament[]>

Example usage:

import { LucraSDK } from 'lucra-react-native-sdk';

try {
  const tournaments = await LucraSDK.getRecomendedTournaments({
    limit: 50,
    includeClosed: true,
  });
  
  tournaments.forEach(tournament => {
    console.log(`Tournament: ${tournament.title}`);
  });
} catch (error) {
  // Handle error scenario
  console.error('Failed to fetch tournaments:', error);
}

tournamentMatchup

Retrieve a tournament with a given ID.

Parameters:

  • tournamentId: ID associated with the tournament.

Returns: Promise<PoolTournament>

Example usage:

joinTournament

Join a tournament with a given ID.

Parameters:

  • tournamentId: ID associated with the tournament.

Returns: Promise<void>

Example usage:

Errors

Errors thrown during tournament operations (getRecomendedTournaments, tournamentMatchup, joinTournament) follow a consistent error structure to help determine the appropriate user-facing message and recovery action.

Error Types

User State Errors (account-related issues):

  • notInitialized - User session not properly set up or account data missing

  • unverified - User hasn't completed identity verification (KYC) for real-money tournaments

  • notAllowed - User account restricted, suspended, or banned

  • insufficientFunds - Not enough balance for paid tournament entry

  • missingDemographicInformation - Missing email/zip code for free tournaments

Location Errors:

  • LocationError - Geographic restrictions (banned states, location services disabled, GeoComply failure)

API Errors:

  • APIError - Network issues, server errors, invalid responses, rate limits

These errors occur during tournament operations (retrieve, join, query) and help determine the appropriate response and error handling strategy.

Error Handling Example

Type Definitions

PoolTournament

PoolTournamentParticipant

Events

Tournament Joined Event

Subscribe to tournament join events to track when users successfully join tournaments:

The onTournamentJoined callback is triggered after a user successfully joins a tournament, providing the tournament ID for tracking and UI updates.

Usage Examples

1. Joining Tournaments with Automatic Error Handling

2. Launching Demographic Form Independently

3. Manual Demographic Data Validation

Check if user has required demographic data before tournament operations:

Migration Guide

For Existing Integrators

If you're updating from an older SDK version:

  • Additive change - existing tournament joining code continues to work

  • New error handling - add handling for missingDemographicInformation error

Example Migration

Before:

After:

Troubleshooting

Common Issues

Demographic form not launching for free tournaments

  • Ensure user authentication is complete before attempting to join tournaments

Form not auto-filling previously entered data

  • The form should auto-fill based on saved user data. If not working, check user authentication state

missingDemographicInformation error not being handled

  • Add the new error case to your tournament joining error handling

Last updated