PollarPollar
SDK Reference

@pollar/react

React hooks and pre-built UI components for Pollar. Built on top of @pollar/core.

npm install @pollar/react

<PollarProvider>

Wraps your application root. Required for all hooks and components to work. Internally renders the login, transaction, KYC, ramp, tx history, and wallet balance modals — you do not need to mount them manually.

import { PollarProvider } from '@pollar/react';

<PollarProvider
  config={{ apiKey: 'pub_testnet_xxxxxxxxxxxxxxxxxxxx' }}
>
  <App />
</PollarProvider>

Props:

PropTypeRequiredDescription
configPollarClientConfigYesClient configuration. See @pollar/core for all available options.
stylesPollarStylesNoStyle overrides applied on top of the remote configuration.

PollarClientConfig:

OptionTypeDefaultDescription
apiKeystringRequired. Your Pollar API key.
stellarNetworkStellarNetwork'testnet'Target network: 'testnet' or 'mainnet'.
baseUrlstring'https://sdk.api.pollar.xyz'Override the Pollar API base URL.

usePollar()

The primary hook. Provides access to all Pollar functionality from a single import. Must be used inside <PollarProvider>.

'use client';
import { usePollar } from '@pollar/react';

function MyComponent() {
  const {
    isAuthenticated,
    walletAddress,
    login,
    logout,
    buildTx,
    signAndSubmitTx,
    transaction,
    txHistory,
    network,
    setNetwork,
    getBalance,
    getClient,
    openLoginModal,
    openTransactionModal,
    openKycModal,
    openRampWidget,
    openTxHistoryModal,
    openWalletBalanceModal,
    config,
    styles,
  } = usePollar();
}

Authentication

PropertyTypeDescription
isAuthenticatedbooleanWhether the user has an active session.
walletAddressstringPublic key of the authenticated wallet. Empty string if not authenticated.
login(options: PollarLoginOptions) => voidInitiates an authentication flow.
logout() => voidSigns out the current user and clears the session.

PollarLoginOptions:

ValueDescription
{ provider: 'google' }Opens Google OAuth flow.
{ provider: 'github' }Opens GitHub OAuth flow.
{ provider: 'email', email: string }Sends an OTP code to the provided email address.
{ provider: 'wallet', type: WalletType }Connects a Stellar wallet (Freighter or Albedo).

Transactions

PropertyTypeDescription
transactionTransactionStateCurrent transaction state (reactive).
buildTx(operation, params, options?) => Promise<void>Builds an unsigned Stellar transaction.
signAndSubmitTx(unsignedXdr: string) => Promise<void>Signs and submits the built transaction.
openTransactionModal() => voidOpens the transaction modal programmatically.

The transaction modal opens automatically when buildTx is called. See @pollar/core for TransactionState step details.


Network

PropertyTypeDescription
networkStellarNetworkCurrently active network.
setNetwork(network: StellarNetwork) => voidSwitches the active Stellar network.

Wallet Balance

PropertyTypeDescription
getBalance(publicKey?: string) => Promise<WalletBalanceContent | null>Fetches balances for the given public key. Uses the authenticated wallet if omitted.
openWalletBalanceModal() => voidOpens the wallet balance modal.

Transaction History

PropertyTypeDescription
txHistoryTxHistoryStateCurrent tx history state (reactive).
openTxHistoryModal() => voidOpens the transaction history modal.

KYC

PropertyTypeDescription
openKycModal(options?: { country?: string; level?: KycLevel; onApproved?: () => void }) => voidOpens the KYC verification modal.
OptionTypeDefaultDescription
countrystring'MX'ISO 3166-1 alpha-2 country code to filter providers.
levelKycLevel'basic'Required KYC level: 'basic', 'intermediate', or 'enhanced'.
onApproved() => voidCallback invoked when the KYC verification is successfully approved.

Ramps

PropertyTypeDescription
openRampWidget() => voidOpens the fiat on/off-ramp widget.

Utilities

PropertyTypeDescription
getClient() => PollarClientReturns the underlying PollarClient instance for direct API access.
configPollarConfigApplication configuration fetched from the Pollar Dashboard.
stylesPollarStylesResolved styles, merging remote config with any local overrides.

Modal entry points

All Pollar modals are mounted inside <PollarProvider> and controlled programmatically:

FunctionDescription
openLoginModal()Opens the login modal.
openTransactionModal()Opens the transaction modal.
openKycModal(options?)Opens the KYC modal.
openRampWidget()Opens the ramp widget.
openTxHistoryModal()Opens the transaction history modal.
openWalletBalanceModal()Opens the wallet balance modal.

Components

<WalletButton>

Pre-built button that handles the complete authentication flow. When logged out, opens the login modal. When logged in, shows the wallet address with a dropdown for balance, transaction history, and logout.

import { WalletButton } from '@pollar/react';

<WalletButton />

No props required. Appearance is controlled by the styles configuration passed to <PollarProvider>.


<KycModal>

Pre-built KYC verification modal. Can be rendered directly when you need more control than openKycModal() provides.

import { KycModal } from '@pollar/react';

<KycModal
  onClose={() => setOpen(false)}
  country="US"
  level="basic"
  onApproved={() => console.log('KYC approved')}
/>
PropTypeDefaultDescription
onClose() => voidRequired. Called when the user dismisses the modal.
countrystring'MX'ISO 3166-1 alpha-2 country code to filter providers.
levelKycLevel'basic'Required KYC level.
onApproved() => voidCalled when KYC is successfully approved.

<KycStatus>

Displays the current KYC status for the authenticated user.

import { KycStatus } from '@pollar/react';

<KycStatus />

<RampWidget>

Pre-built fiat on/off-ramp widget with support for on-ramp (fiat → crypto) and off-ramp (crypto → fiat) flows.

import { RampWidget } from '@pollar/react';

<RampWidget onClose={() => setOpen(false)} />
PropTypeDescription
onClose() => voidRequired. Called when the user dismisses the widget.

<WalletBalanceModal>

Displays the token balances of the authenticated wallet with a manual refresh option.

import { WalletBalanceModal } from '@pollar/react';

<WalletBalanceModal onClose={() => setOpen(false)} />
PropTypeDescription
onClose() => voidRequired. Called when the user dismisses the modal.

Template components

Template components handle rendering only — they receive all data and callbacks as props and contain no internal logic. Use them to build fully custom UI while reusing Pollar's layout and visual structure.

ComponentDescription
<LoginModalTemplate>Login provider selection and email OTP screens.
<KycModalTemplate>KYC provider selection and verification screens.
<RampWidgetTemplate>Ramp input, quote selection, and payment instruction screens.
<TransactionModalTemplate>Transaction details, signing, and result screens.
<TxHistoryModalTemplate>Transaction history list screen.
<WalletBalanceModalTemplate>Wallet balance screen.

Import the corresponding *Props type for full type safety:

import {
  TransactionModalTemplate,
  type TransactionModalTemplateProps,
  WalletBalanceModalTemplate,
  type WalletBalanceModalTemplateProps,
} from '@pollar/react';

Types

import type {
  PollarConfig,
  PollarStyles,
  AuthProviderProps,
  AuthContextValue,
  LoginButtonProps,
  AuthModalProps,
  KycStep,
  RampStep,
  TransactionModalTemplateProps,
  WalletBalanceModalTemplateProps,
} from '@pollar/react';

Core types such as TransactionState, TxHistoryState, WalletBalanceContent, PollarLoginOptions, StellarNetwork, and WalletType are imported directly from @pollar/core.

On this page

Was this helpful?