Skip to documentation
AdQuestDocs

React components

Props, callbacks and views of the AdQuestWidget and QuestWidget components.

On this page

AdQuestWidget

The lottery-first widget with token balance, entries, claims and the earn-token journey. Import it from @adquest/sdk/react and import @adquest/sdk/styles.css once.

PropTypeMeaning
apiKeystring (required)Your public API key.
baseUrlstring (required)The API URL, including /api/v1.
externalUserIdstring (required)Your ID for the user.
participantTokenstringThe participant token from your backend.
previewTokenstringA Theme Studio preview token.
themeAdQuestThemeTyped theme overrides, such as layoutPreset, colors and copy.
localestringWidget language, en or fa.
initialViewWidgetViewThe first view to show.
autoLoadbooleanLoad data on mount. Defaults to true.
title, descriptionstringHeader text.
classNamestringA class for the root element.
displayNamestringThe participant’s name.
requireProfile, onSubmitProfileboolean, functionAsk for a name and avatar first, and receive them.

Callbacks

CallbackCalled withUse it to
onReadynothingHide your loading indicator.
onCompleteQuestCompleteResultShow completion feedback and refresh your server-backed state.
onEntryLotteryPurchaseShow entry confirmation.
onClaimLotteryClaimShow claim submission feedback.
onNavigate{ view, canGoBack, immersive? }Keep host navigation in sync.
onAuthRequirednothingRefresh the participant token through your backend.
onError{ code, message }Show a recoverable error or account action.
onClosenothingClose the drawer, screen or modal that contains the widget.
hostNavigationbooleanSet true when your app provides the header. The widget hides its own header and shows a Back to platform button on the home page.
onExitnothingThe user pressed Back to platform on the home page. Close or leave the screen that contains the widget.

Views

WidgetView is one of lotteries, lottery-detail, earn-tokens, my-entries, results, claims, quests, history or profile.

A ref to AdQuestWidget exposes navigate(view), getView() and goBack(). goBack() returns false at the root, where your app can close the experience.

QuestWidget

A quest-only placement.

PropTypeMeaning
apiKey, baseUrl, externalUserId, participantTokenstringAs for AdQuestWidget. Optional when wrapped by AdQuestProvider.
themeAdQuestThemeTyped theme overrides.
showHeaderbooleanShow the title row. Defaults to true.
title, description, className, autoLoadmixedAs for AdQuestWidget.
onComplete(result: QuestCompleteResult) => voidCalled when a quest completes.
onBack, onOpenRewards() => voidNavigation hooks for the host.
onQuestFocusChange(focused: boolean) => voidCalled when a quest opens or closes.
resetToListTokennumberChange it to send the widget back to the quest list.
wrapWithProviderbooleanWrap with AdQuestProvider. Set false when you already provide one.

Language and formatting

  • locale (en or fa, region tags such as en-US accepted) sets the widget language. Anything else uses English. Changing the prop updates the widget at once. Quest and lottery content follows the language of the participant session, so create a new session when the language changes.
  • The widget sets lang and dir on its root element. Persian renders right-to-left.
  • Dates and numbers use Intl for the resolved language, with Persian digits and calendar for fa.
  • Quest names and lottery text come from the server and are shown as sent. When the server falls back to another language, that text carries its own lang and dir.
  • Theme copy for startQuest, buyTicket, questsTab and rewardsTab wins when you set a custom value. A missing value, or the original English default (START QUEST, BUY A TICKET, QUESTS, REWARDS, case-sensitive), follows the SDK language instead.

Theme overrides

The widget loads the platform’s published theme. Pass a typed theme to override values in code. A host override beats the published theme, so remove it if you want the dashboard to control that value. Keep @adquest/sdk/styles.css imported for the base layout.

Typed theme overrides
import type { AdQuestTheme } from "@adquest/sdk";

const theme: AdQuestTheme = {
  layoutPreset: "quests_rewards",
  primaryColor: "#ff9a3e",
  borderRadius: "12px",
  colors: {
    background: "#0c0c0c", surface: "#18181a",
    text: "#f5f2ef", muted: "#a39b96",
  },
  currency: { tokenLabel: "Tokens", ticketLabel: "Tickets" },
  copy: { questsTab: "Quests", rewardsTab: "Rewards" },
};
// Pass theme={theme} to AdQuestWidget or QuestWidget.

Use the typed theme instead of overriding internal class names. Check text contrast, small screens, loading and error states, and long translations.

Default spacing

The default design spaces everything on a 4px base unit and an 8px grid. Every padding, margin and gap in @adquest/sdk/styles.css uses one of the steps below, so spacing stays consistent from screen to screen. The scale is fixed: it is not a theme value, and neither Theme Studio nor a typed theme can change it.

StepSizeTypical use
--adquest-space-14pxGaps between an icon and its label, tight text stacks.
--adquest-space-28pxGaps between small items, badge and chip padding.
--adquest-space-312pxField and list-item padding.
--adquest-space-416pxCard padding, gaps between related blocks.
--adquest-space-520pxSide padding of a screen.
--adquest-space-624pxSheet padding, gaps between sections.
--adquest-space-8, -10, -12, -1632px, 40px, 48px, 64pxLarge breaks, such as the top of a sheet.
  • Controls drawn smaller than 44px (the currency icon buttons, the header back button and the quantity stepper) keep their look and have an invisible 44px tap area.
  • Values you set in a typed theme, such as card padding, button height and quest card content spacing, still apply. Only the defaults, used when you set nothing, sit on the scale.
  • The variables are internal. Do not read or override --adquest-space-* in your own CSS, because they can change between versions.
  • Persian (fa) renders right-to-left with the same spacing.

Components and hooks

For a custom interface, @adquest/sdk/react also exports AdQuestProvider, ClaimCountdown, ClaimsView, CurrencyBar, LotteryDetailView, LotteryList, LotteryResultsView, LotteryWinnerList, MyEntriesView, ParticipantGate, QuestModal, QuestList, QuestDetail, QuestPlayer, QuestStepper, QuestResultSheet, ResultPanel and RewardHistoryView, plus the hooks useAdQuest, useBalanceHistory, useLotteries, useLotteryClaims, useLotteryEntry, useParticipantSession, useQuestSession and useTokenBalance.

Something unclear, missing or wrong here? Tell us