> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/embed/embedding/sdk.md).

# SDK

The SDK mounts the same iframe and adds events, token refresh, theming and modal mode.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-f2d796f6d58973eaf61cfc2df513e73ae7aa9f8c%2Fwidget-embed-sdk.jpg?alt=media" alt="The Embed tab with SDK selected, a USER selector naming the customer the snippets are scoped to, and expandable variants starting with Connect card from @fastn-ai/embed/react and React component below it"><figcaption><p>Each variant expands to the exact snippet for the user you selected.</p></figcaption></figure>

The SDK mounts the same iframe and adds what a raw tag cannot: events when a user connects an app, token refresh, live theming, and modal mode.

Four variants, depending on how much of the UI you want to own:

| Variant               | Package path               | Use when                                                           |
| --------------------- | -------------------------- | ------------------------------------------------------------------ |
| **React component**   | `@fastn-ai/embed/react`    | Your app is React and you want the whole panel.                    |
| **Connect card**      | `@fastn-ai/embed/react`    | You want the smallest surface: one card, one button.               |
| **Script tag**        | hosted bundle, no install  | Vue, Svelte, Rails, plain HTML: anything that runs JS.             |
| **Build your own UI** | `@fastn-ai/embed/headless` | The integrations screen has to look like the rest of your product. |

### React

The confirmed exports are `FastnConnectCard`, `FastnHub` and `FastnProvider`; the headless entry point exposes the hooks `useConnectors`, `useConnections` and `useConnect`.

`FastnProvider` supplies the session the other components read, so wrap your tree in it rather than mounting `FastnHub` bare. Copy the exact props from the dashboard's generated snippet. They are rendered there for the user you selected.

### Script tag

Not an npm install: a hosted bundle you load with a `<script>` tag.

```html
<script src="https://YOUR_FASTN_HOST/api/v1/embed/assets/fastn-embed.min.js"></script>
```

```javascript
const hub = FastnEmbed.createFastnEmbed({ /* config from the Embed tab */ });

hub.mount('#hub');   // inline
hub.open();          // or as a modal

hub.on('connected', (e) => {
  // Refresh your app's data after the user connects an integration.
});
```

Because fastn hosts the screen, it gains features without you shipping a release, and its styles can never collide with yours.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fastn.ai/embed/embedding/sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
