Skip to content

Initialization

Initialize Privy as early as possible in your game’s lifecycle. To initialize, simply call PrivyManager.Initialize(PrivyConfig config) as shown below:

csharp
var config = new PrivyConfig{
    AppId = "YOUR_APP_ID",
    ClientId = "CLIENT_ID"
};

PrivyManager.Initialize(config);

To get the Privy app ID and client ID for your application, go to the Privy Dashboard and navigate to the *Settings** page. You can get these values from the **Clients** tab of this page.

AwaitReady

When the Privy SDK first initializes, the user's AuthState will be set to NotReady until Privy finishes initialization. This may involve refreshing a user's access token, fetching the updated user object for the user, loading the embedded wallet iframe, and more.

You should not use Privy's variables or methods until your AuthState updates to a value other than NotReady.

To handle these cases, the Privy SDK offers an AwaitReady() function that allows you to await until Privy is ready to be used. During this time, we suggest you show a loading state to your user. Here's an example with some pseudocode:

csharp
// Show loading screen

// Initialize Privy

// Await Privy ready
await PrivyManager.AwaitReady();

// Privy is ready, show loaded screen

You can also check whether Privy is ready at any time by calling:

csharp
PrivyManager.Instance.IsReady