Skip to content

SDK Initialization

AIR Kit creates an iframe that loads the login flow and sets up communication streams between the iframe and the DApp's JavaScript context.

js
import { AirService, BUILD_ENV } from "@mocanetwork/airkit";

const airService = new AirService({
  partnerId: YOUR_PARTNER_ID // Replace with your actual Partner ID
});
await airService.init({
  buildEnv: BUILD_ENV.SANDBOX,
  credentialNetwork: "devnet", // Optional: testnet (default) or devnet
  enableLogging: true,
  preloadWallet: true, // Optional: Enable if wallet features will be used
  preloadCredential: true, // Optional: Enable if credential features will be used
  sessionConfig: {
    locale: "en", // Optional: Language code (e.g. "en", "es", ...)
    currency: "USD" // Optional: Display currency (e.g. "EUR", "USD", ...)
  }
});

// Without any parameters, this will trigger the default Air login dialog which provides different login methods for the user to choose from.
await airService.login();

Once the SDK is installed and AirService is successfully initialized, it can be used to authenticate users.