Docs/Installation/Web SDK Integration

Web SDK Integration

Install @adquest/sdk and render AdQuestWidget or QuestWidget in React.

Install

npm install @adquest/sdk

Lottery-first widget

import { AdQuestWidget } from "@adquest/sdk/react";
import "@adquest/sdk/styles.css";

export function Rewards({ participantToken }: { participantToken: string }) {
  return (
    <AdQuestWidget
      apiKey={process.env.NEXT_PUBLIC_ADQUEST_PLATFORM_API_KEY!}
      baseUrl="https://api.adquest.io/api/v1"
      externalUserId="host-user-123"
      participantToken={participantToken}
      onEntry={(purchase) => console.log(purchase)}
      onComplete={(result) => console.log(result.tokensAwarded)}
      onClaim={(claim) => console.log(claim)}
      onNavigate={(state) => console.log(state.view, state.canGoBack)}
      onAuthRequired={() => refreshParticipantSession()}
      onReady={() => console.log("ready")}
      onError={(error) => console.error(error.code, error.message)}
      onClose={() => console.log("close")}
    />
  );
}

Quest-only widget

import { QuestWidget } from "@adquest/sdk/react";

Use when the host only needs quests without lottery chrome.

Imperative ref

widgetRef.current?.navigate("lotteries");
widgetRef.current?.goBack();
widgetRef.current?.getView();

goBack() returns false at the root view so the host can close its sheet.