> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gameball.co/llms.txt
> Use this file to discover all available pages before exploring further.

# How Do I Initialize the React Native SDK (v4)?

> Initialize Gameball React Native SDK with your configuration

# Initialize the SDK

Initialize Gameball at app startup, typically in your root component or `App.tsx`:

🔒

**Secure API Access:** To benefit from v4.1 secure API endpoints, pass the `sessionToken` parameter during SDK initialization (required in upcoming SDK v4). This enables automatic routing to v4.1 secure endpoints. [Learn more about v4.1 →](https://docs.gameball.co/api-reference/introduction-v4.1.md)

```typescript theme={null}
import { GameballApp, GameballConfig } from 'react-native-gameball';
import { useEffect } from 'react';

function App() {
  useEffect(() => {
    const config: GameballConfig = {
      apiKey: 'your-api-key',             // Required
      lang: 'en',                         // Required
      shop: 'your-shop-id',               // Optional
      platform: 'your-platform-id',       // Optional
      sessionToken: 'your-session-token', // Optional - secure authentication
    };

    GameballApp.getInstance().init(config);
  }, []);

  return (
    // Your app components
  );
}
```

## Configuration Parameters

**apiKey** `string` *required*

The client API key available in your Gameball dashboard (required).

**lang** `string` *required*

Language code: 'en' or 'ar' (required).

**shop** `string`

Your Gameball shop identifier for multi-shop configurations.

**platform** `string`

Platform identifier (optional, set if you manage multiple platforms).

**sessionToken** `string`

Session Token for secure authentication (enables automatic v4.1 endpoint routing). Required in upcoming SDK v4.

### Validation Rules

**GameballConfig requires:**

* API key is required (cannot be null)
* Language is required (cannot be null)

## Using Async/Await

You can use async/await for initialization if needed:

```typescript theme={null}
import { GameballApp } from 'react-native-gameball';

async function initializeGameball() {
  try {
    const config: GameballConfig = {
      apiKey: 'your-api-key',
      lang: 'en',
      shop: 'your-shop-id',
      platform: 'your-platform-id',
      sessionToken: 'your-session-token',
    };

    await GameballApp.getInstance().init(config);
    console.log('Gameball SDK initialized successfully');
  } catch (error) {
    console.error('Failed to initialize Gameball:', error);
  }
}
```

> [!TIP]
>
> Initialize the SDK as early as possible in your app's lifecycle to ensure it's ready when you need to track events or show the profile widget.

> [!WARNING]
>
> Make sure to use your actual API key from the Gameball dashboard. Test keys are for development, production keys are for live deployment.

## Next Steps

* [Initialize Customer Profile](https://docs.gameball.co/installation-guides/v4/react-native/initialize-profile.md)
* [Track Customer Events](https://docs.gameball.co/installation-guides/v4/react-native/track-events.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.