# Building with the packages

Two packages cover most of an integration: a typed client for your server, and Fin's blocks for
your React chat. Use either one alone, or both together.

- [**Server SDK**](/sdk-quickstart) — `@nearai/financial-agents-sdk`: every operation, typed, with sessions, retries and live streams handled.
- [**React components**](/react-quickstart) — `@nearai/financial-agents-react`: Fin's replies, approvals, questions and result cards, inside your own chat.

> [!NOTE]
> The packages are not on npm yet. They publish with their first release.

## How they fit

Your API key and your users' sessions stay on your server. The SDK talks to Fin, your server
relays the conversation, and the React package draws it.

1. **Your server** creates the user, opens their session after your own sign-in, and starts a
   run for each message: `users.create`, `users.createSession`, `runs.start`.
2. **Your server** follows the conversation with `events.stream` and relays each event to the
   page.
3. **Your page** folds the events with `threadReducer`, and draws Fin's entries with `FinEntry`
   beside your own message bubbles.
4. **The user** decides an approval or answers a question; your server sends it with
   `approvals.approve`, `approvals.deny` or `questions.answer`.

Neither package needs the other: use the SDK under your own interface, or the components over
data your server reads by HTTP.

## Install

```sh
npm install @nearai/financial-agents-sdk                   # on your server
npm install @nearai/financial-agents-react @base-ui/react  # in your React app
```

## Requirements

| | `@nearai/financial-agents-sdk` | `@nearai/financial-agents-react` |
| --- | --- | --- |
| Runs on | Your server: Node 20+, Bun, Deno, edge runtimes | The browser, and your server for server rendering |
| Peer dependencies | None | React 19, `react-dom` 19, `@base-ui/react` 1.3+ |
| TypeScript | 5.4+ | 5.4+ |
| Entry points | `@nearai/financial-agents-sdk` | `@nearai/financial-agents-react`, `/model`, `/fixtures`, `/styles.css` |

## Money needs the user's signature

Creating the agent wallet, withdrawing and approving a trade each carry the user's wallet
signature of the exact message Fin issued. Fin verifies it on arrival and again before anything
is signed.

> [!IMPORTANT]
> Before your page asks the user to sign, check the message with the SDK's `isAuthorizationFor`,
> so the user only ever signs a Fin authorization of their own. The
> [recipe](/sdk-recipes#money-needs-the-user-s-signature) shows how.

The approval card shows the exact terms of the contract Fin derived, never the model's words. A
contract the card cannot read offers only Cancel: nobody approves terms they were not shown.

## Next steps

- [**SDK quickstart**](/sdk-quickstart) — Create a user, open a session and stream a reply.
- [**React quickstart**](/react-quickstart) — Draw a Fin conversation in your own chat.
- [**SDK recipes**](/sdk-recipes) — Relaying, approvals, funding, withdrawals and errors.
- [**Theming**](/react-theming) — Your palette, your classes, or your own markup.
- [**SDK reference**](/sdk-reference) — Every method, option, error and type.
- [**Components reference**](/react-components) — Every block, its props and its parts.
