Skip to main content
The yield widget is a full Earn interface in one package, @stakekit/widget. It covers yield discovery, wallet connection, and the enter, exit and manage flows. It calls the Earn API with your project’s API key and shows only the yields enabled for that project. See Discover yields. This guide covers the classic layout. For the dashboard layout with Borrow, Manage and Activity tabs, see Widget Pro. For Perps, see the Perps widget.

Prerequisites

  • A Yield.xyz API key for the project whose yields you want to show. See API keys.
  • React 19 or later if you use the React entry point (SKApp). The browser renderer (renderSKWidget) does not require React on the host page.
The API key ships to the browser in every widget deployment. Read the security notice for the risks and how to limit them.

Install

@stakekit/widget exposes three entry points: the package root (SKApp, for React apps), ./bundle (renderSKWidget, framework-agnostic) and ./style.css (the stylesheet, required by both). If your app already uses React, the React entry point keeps your bundle smaller.

React

Import the stylesheet once, then render SKApp with your API key:

Next.js

Render the widget in a client component and load it without server-side rendering:

Browser renderer

renderSKWidget mounts the widget into a container element without React in your app:
Only one widget can be mounted on a page at a time. Unmount it before you mount another.

From a script tag

Without a bundler, load the bundle and its stylesheet from a CDN:
If your page’s styles leak into the widget, mount the widget in a container inside a shadow root and pass that container as portalContainer so that dialogs and menus also render inside it.

Wallet and signing

By default the widget renders its own connect-wallet flow and signs with the wallet the user connects. To sign with your own signer, custody provider or embedded wallet instead, pass externalProviders:
  • sendTransaction(tx, txMeta) signs and broadcasts one transaction. tx.type is evm, solana, ton, tron or bittensor. Once the transaction is broadcast, resolve with { type: "success", txHash }. Resolve with { type: "cancelled" } when the user declines, or { type: "error", error } on failure. A plain hash string also works.
  • signMessage(message) returns the signature string, or the same success, cancelled or error result.
  • switchChain(chainId) resolves once your wallet is on that chain. Update currentChain afterward.
  • currentAddress is "" while the wallet is disconnected. Keep externalProviders in place; adding or removing it requires a remount.
The widget constructs each transaction, and your provider signs and sends it. As with direct API use, your provider inspects every transaction before sending it. txMeta carries the action type, transaction type, amounts and validators, so you can label the request that your users or approvers see. To offer Zama confidential vaults with your own wallet, give the provider a signZamaPermit(typedData, meta) method (type SKZamaWallet). Without it, Zama deposits are blocked. See Zama. To add Borrow to the same widget, see the Borrow widget guide.

Tracking

Pass tracking to receive the widget’s analytics events:
trackEvent fires on interactions such as "Connect wallet clicked", "Yield selected", "Transaction signed" and "Transaction submitted". trackPageView fires on screens such as "Earn", "Positions", "Stake review" and "Stake complete". The SKTrackEvent and SKTrackPage types list every value.

Theming

lightTheme and darkTheme are the built-in themes. Pass a partial theme as theme: it is deep-merged over the light theme, so you set only the tokens you change.
To follow the user’s light or dark preference, choose lightTheme or darkTheme based on prefers-color-scheme in your app and pass it as theme.
Every token is a CSS value string. All groups are optional.The connectKit color and radius groups were removed in 0.0.290. Remove them from your theme if you set them.

Configuration reference

Every prop below is optional except apiKey. Props marked Mount are read when the widget mounts; remount it to change them. The rest update live.
The package exports the chain id constants (EvmChainIds, MiscChainIds, SubstrateChainIds), DashboardYieldCategory, the themes, and a named type for every prop. Import them rather than copying their shapes.

Upgrading to 0.0.290

  • React 19. The react and react-dom peers are >=19.
  • Wallet dialogs. RainbowKit is replaced by the widget’s own connect, account and chain dialogs and its own WalletConnect. Existing Tron, Cosmos and Polkadot WalletConnect sessions reconnect once after the update.
  • Removed: forceWalletConnectOnly, the color.connectKit and borderRadius.connectKit theme groups, wagmi.__customConnectors__ and mapWalletListFn (use walletPolicy), disableGasCheck, and the createWallet, evmChainGroup and TrackingContextProvider exports.
  • Adapter results. sendTransaction and signMessage can resolve { type: "cancelled" } when the user declines; the widget shows a retryable notice.
  • Browser renderer. renderSKWidget returns { rerender, unmount }.
  • Deprecated, no effect: tokensForEnabledYieldsOnly and externalProviders.supportsBorrow. Remove them.

Verify

Run your app and confirm three things. The widget loads your project’s yields, matching what GET /v1/yields returns for the same API key. Connecting a wallet, or passing externalProviders, shows a balance. A transaction signs and settles as described in Enter and exit flows.

Next steps

Widget Pro

The dashboard layout of the same widget, with Borrow, Manage and Activity tabs.

Borrow widget

Turn on Borrow in the widget.

Enter and exit flows

What the widget’s enter, exit and manage flows do at the API level.

Discover yields

Confirm which yields your project’s API key exposes.