# Terra SDK and widgets: integrate Terra Wallet anywhere

> A crypto wallet SDK and web3 wallet SDK widgets: connect buttons, wallet modals and checkout for React and Web Components, plus server SDKs. Early access.

Source: https://developers.terrawallet.us/sdk

**Status:** The Terra SDK and widgets are in early access. Package names may change before launch.

## A crypto wallet SDK and widgets for any app

Add Terra Wallet and Terra Pay to any app in minutes. A web3 wallet SDK with drop-in widgets as light and polished as the Terra Wallet extension, typed server clients and mobile helpers. Try the widgets and theme them live.

## One web3 wallet SDK family for every stack

- **connect (@terrawallet/connect)**: The core. Finds Terra Wallet (EIP-6963, Wallet Standard), falls back to WalletConnect v2 with a QR or deep link. Sessions, chain switching, sign and send. Target under 15 KB gzipped.
- **react (@terrawallet/react)**: `<ConnectButton/>`, `<WalletModal/>` and hooks, plus a wagmi/viem connector and a Solana wallet-adapter, so it slots into existing dApps.
- **pay-js (@terrawallet/pay-js)**: `<TerraCheckout/>` as a modal or inline, `TerraPay.open({ paymentId })`, and a subscribe button.
- **elements (@terrawallet/elements)**: Web Components (`<terra-connect-button>`, `<terra-pay-button>`) for any site, WordPress, Webflow or plain HTML, through one script tag with an SRI hash.
- **Server SDKs (Node, Python, PHP)**: Typed clients for the `/v1` API with webhook-verification helpers. Go later.
- **Mobile (React Native, Android, iOS)**: A React Native SDK and Android and iOS deep-link helpers. Flutter later.
- **Embedded Wallet (Later phase)** (Later): A non-custodial wallet inside your app, with white-label UI. See [Embedded Wallet](/embedded-wallet).

_Package names are illustrative and subject to an npm availability check, for example `@terrawallet/*`._

## Compact, clean, and impossible to spoof

- The extension's visual language: compact, clean, automatic dark and light, subtle motion, official network logos.
- Theming tokens for accent, radius, font and light, dark or auto. Terra's security prompts can't be hidden or restyled.
- Rendered in Shadow DOM, so the host page's CSS can't break or spoof it.
- WCAG AA, keyboard and screen-reader support, and translations including right-to-left languages.
- Mobile-first: on a phone, Connect opens the Terra app directly and returns automatically.

## What integrating will look like

Preview code for the planned API. It shows the shape of the SDK, not a final contract.

React (Preview API, subject to change):

```tsx
// Preview API, subject to change. Package names may change.
import { TerraProvider, ConnectButton, useAccount } from "@terrawallet/react";

export function App() {
  return (
    <TerraProvider
      publishableKey="tw_test_pk_..."   // safe in the browser
      theme={{ accent: "#0A5BFF", mode: "auto" }}
    >
      <ConnectButton />
      <Balance />
    </TerraProvider>
  );
}

function Balance() {
  const { address, chain } = useAccount();
  return address ? <p>{chain.name}: {address}</p> : null;
}
```

pay-js (Preview API, subject to change):

```js
// Preview API, subject to change. Package names may change.
import { TerraPay } from "@terrawallet/pay-js";

document.querySelector("#checkout").addEventListener("click", () => {
  // paymentId comes from your server (see the server tab)
  TerraPay.open({ paymentId: "pay_8Hk2Qm", theme: { mode: "auto" } });
});
```

elements (Preview API, subject to change):

```html
<!-- Preview API, subject to change. One script tag, pinned per version
     with an SRI hash. The real URL and hash are published at launch. -->
<script type="module" src="TERRA_ELEMENTS_URL"
        integrity="sha384-PINNED_HASH" crossorigin="anonymous"></script>

<terra-connect-button theme="auto"></terra-connect-button>
<terra-pay-button payment-id="pay_8Hk2Qm"></terra-pay-button>
```

Node (Preview API, subject to change):

```ts
// Preview API, subject to change. Package names may change.
import { Terra } from "@terrawallet/server";

const terra = new Terra(process.env.TERRA_SECRET_KEY); // tw_test_sk_...

const payment = await terra.payments.create(
  { amount: "120.00", currency: "USD", accept: ["USDC", "USDT"], orderId: "1042" },
  { idempotencyKey: "order-1042" },
);

// Send your customer to payment.checkoutUrl (pay.terrawallet.us/c/...)
```

Python (Preview API, subject to change):

```python
# Preview API, subject to change. Package names may change.
import os
from terrawallet import Terra

terra = Terra(api_key=os.environ["TERRA_SECRET_KEY"])

payment = terra.payments.create(
    amount="120.00", currency="USD", accept=["USDC", "USDT"],
    order_id="1042", idempotency_key="order-1042",
)
```

## Built for a five-minute first payment

- **Quick start**: A five-minute [quick start](/developers) and copy-paste snippets.
- **Playground**: An interactive playground on this site, starting with the widget preview above.
- **Instant sandbox keys**: Test keys from the dashboard the moment you sign up.
- **Webhook CLI**: A CLI that forwards webhooks to localhost while you build.
- **OpenAPI**: An OpenAPI 3.1 spec with typed clients and examples.
- **Example apps**: A Next.js store, a subscription SaaS and a Telegram bot.

## An SDK you can safely depend on

- npm provenance, two-factor publishing, a lockfile, minimal dependencies, an SBOM and audits in CI.
- CDN scripts pinned per version with Subresource Integrity hashes.
- No remote code loading and no `eval`. Compatible with strict CSP and Trusted Types.
- Front-end code uses publishable keys (`tw_test_pk_`, `tw_live_pk_`) locked to the origins you allow. Secret keys never go in a browser or app.

## Frequently asked questions

### Is the Terra SDK available now?

Not yet. The SDK and widgets are in early access, and the code on this page is a Preview API, subject to change.

### What will the packages be called?

Names are illustrative and subject to an npm availability check, for example `@terrawallet/connect` and `@terrawallet/react`.

### Does it work with wagmi and viem?

The planned `react` package includes a wagmi/viem connector and a Solana wallet-adapter, so it slots into existing dApps.

### Can I use it without React?

Yes. The `elements` package provides Web Components for any site, through one script tag pinned with an SRI hash.

### Can I restyle the widgets?

Yes: accent, radius, font and light, dark or auto. Terra's security prompts can't be hidden or restyled.

### Which server languages are planned?

Node and TypeScript, Python and PHP first, with Go later. See the [developer quick start](/developers).
