Skip to main content
The examples in this section are complete React components for a Next.js App Router project using wagmi and viem. They all import the same two files, a shared SDK client and a set of formatting helpers, so set those up once and every example drops in as written.
Not on Next.js? Nothing here depends on the framework except the "use client" directive and the @/ import alias. The components work in any React app with wagmi and TanStack Query installed.

Install

The Client

Create the SDK client once at module scope. It is frozen and immutable, so sharing it is safe.
lib/tbi.ts

Building Against Staging

Staging runs the same API and SDK surface against test campaigns. Those campaigns track real positions on mainnet chains but pay rewards on Base Sepolia (chain 84532), so you can deposit into your actual vault and claim test tokens without spending real rewards. Ask the team in your partner channel or on Discord for the ID of the staging campaign to build against. There is no self-serve way to create one.

Providers

Wrap your app in wagmi and TanStack Query. Include every chain your campaigns pay on, plus Base Sepolia while you are on staging. The wallet has to be on the reward chain to claim and on the event chain to deposit, so both need to be in the config.
app/providers.tsx
app/layout.tsx
The 60 second staleTime matches how often campaign stats actually change. Polling faster only spends your rate limit. See Caching and Polling.

Formatting Helpers

Every amount the SDK returns is a bigint in base units, APRs are basis points, and campaigns carry no display name. These helpers turn all of that into strings for the UI.
lib/format.ts
You know your own pools better than the API does. Most integrations replace campaignLabel with a lookup from campaign.target.address to their own pool name and icon.

Persisting the Query Cache

TanStack Query’s in-memory cache handles bigint fine. If you persist the cache to localStorage or IndexedDB, JSON.stringify throws on the first response. The serializer pair is in Data Conventions.

The Examples

Opportunities List

Live campaigns with reward APR, TVL, and time remaining.

Rewards Panel

What the connected wallet has earned and can claim.

Claim Button

Switch chain, simulate, submit, and update the UI.

Deposit Button

Route a deposit through the Forwarder when a campaign requires it.