Skip to main content
The Perps widget is a compact perpetual futures trading app you host and embed in your product. Users open long and short positions on Hyperliquid with leverage, manage them, and fund their account, all signed in their own wallet. It is built on the Perps API and sized for a 400 by 600 pixel slot in a wallet, exchange or fintech app. For a full desktop trading terminal instead, see the Perps dashboard. Both come from the same source repository.
Perps trading carries jurisdictional restrictions, and the Perps API blocks requests from banned regions. Read the perpetuals disclaimer and Geo-blocking before you deploy.

What users can do

  • Open long and short positions with adjustable leverage.
  • Place market and limit orders, and set take profit and stop loss.
  • Increase, partially close or close a position, adjust its margin and change its leverage.
  • Cancel open orders.
  • Deposit to and withdraw from their Hyperliquid account.
  • See live prices, positions and account balance.
  • Connect a wallet through WalletConnect.
Every action returns unsigned transactions or payloads from the Perps API, and the user signs them in their own wallet. Yield.xyz never holds keys.

Prerequisites

  • A Yield.xyz API key with the Perps API enabled. The same project key works for the Earn, Perps and Borrow APIs.
  • A Moralis API key, used to read wallet token balances.
  • Optional: a Reown project ID for WalletConnect.
  • Node.js 24 and pnpm 10, as pinned in the repository’s mise.toml. pnpm 11 stops the install on unapproved build scripts, so use pnpm 10.

Run it locally

1

Clone and install

2

Set environment variables

Each app reads its own .env. For the widget:
packages/widget/.env
VITE_PERPS_BASE_URL, VITE_PERPS_API_KEY and VITE_MORALIS_API_KEY are required. VITE_REOWN_PROJECT_ID is optional.
3

Start the dev server

Open http://localhost:3000.
Every VITE_ variable is bundled into the browser build, so treat these keys as public. Restrict them where the provider allows it, for example with allowed origins, and see the security notice.

Build and deploy

The build output is written to packages/widget/dist. Deploy it to any static host that serves single-page apps, with every path routed to index.html. The repository’s vercel.json configures this for Vercel. Set the environment variables in your host’s build settings, since they are read at build time.

Embed it

After you deploy the widget, embed it on your own domain with an iframe:
Serve the widget over HTTPS. If you set a Reown project ID, add your domain to the allowed domains of that Reown project.

How it works

The widget calls the Perps API at https://perps.yield.xyz with your API key: The Perps API guide walks through the same flow for teams that build their own interface.

Customize it

You can modify the source under the terms of its license:
  • Styling. The apps use Tailwind CSS v4. Change colors, fonts and spacing in the app styles and components.
  • Features. Screens are file-based routes in packages/widget/src/routes. Shared API clients, state and components are in packages/common.
  • Wallets. Wallet connection uses Reown AppKit and wagmi, and is configured in the app’s context providers.

Troubleshooting

Check that VITE_PERPS_BASE_URL, VITE_PERPS_API_KEY and VITE_MORALIS_API_KEY are set for the app you build, and that the key has the Perps API enabled. Variables are read at build time, so rebuild after changing them.
Check your VITE_REOWN_PROJECT_ID, that your domain is allowed in the Reown project, and that browser extensions are not blocking WalletConnect. Some wallet extensions do not inject into an iframe. Open the app in its own tab to compare.
Use Node.js 24 and pnpm 10. With pnpm 11 the install stops on unapproved build scripts. To start over, delete node_modules and run pnpm install again.

License

The Perps widget is published under the Business Source License 1.1 (BSL-1.1), which converts to MIT on 2030-01-20. Read the LICENSE file in the repository before you deploy it.

Next steps

Perps dashboard

The full desktop trading terminal from the same repository.

Perps API guide

Build your own Perps interface on the same API.