> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Kom i gang med Element Sessions

> Opsæt de forældede @whop/embedded-components-pakker. Til nye chatintegrationer skal du bruge @whop/elements.

## Oversigt

Det primære indgangspunkt for Whops indlejrede komponenter.

WhopElements er rodobjektet, der administrerer konfigurationen og opretter
chatsessionen. Initialiser det én gang, og brug det til at oprette den session, der monterer chat-,
DM- og søgeelementer.

## Installation

```bash React theme={null}
npm install @whop/embedded-components-vanilla-js @whop/embedded-components-react-js
```

```bash Vanilla JS theme={null}
npm install @whop/embedded-components-vanilla-js
```

## Eksempler

### Grundlæggende initialisering

```typescript theme={null}
import WhopElements from "@whop/embeddable-components";

const whopElements = new WhopElements({
  appearance: {
    theme: { appearance: "light" },
  },
  locale: "en",
});
```

### Oprettelse af en chatsession

```typescript theme={null}
const session = whopElements.createChatSession({
  token: async () => {
    // Fetch token from your backend
    const response = await fetch("/api/token");
    const data = await response.json();
    return data.token;
  },
});

const element = session.createElement("chat-element", {
  channelId: "feed_XXXXXXXXXXXXXX",
});
element.mount("#chat-container");
```

### Opdatering af indstillinger efter initialisering

```typescript theme={null}
// Switch to dark mode
whopElements.updateOptions({
  appearance: {
    theme: { appearance: "dark" },
  },
});
```

### Lyt efter ændringer i indstillinger

```typescript theme={null}
whopElements.on("optionsUpdated", (options) => {
  console.log("Options changed:", options);
});
```

## Indstillinger

| Egenskab | Type | Påkrævet | Standard | Beskrivelse |
| - | - | - | - | - |
| `appearance` | [`Appearance`](https://docs.whop.com/da/sdk/elements/types#appearance) \| undefined | Nej | - | Tilpas udseendet af Whops indlejrede Elements. Omfatter temaindstillinger som lys/mørk tilstand og accentfarver. |
| `locale` | `"en" \| "es" \| "zh" \| "nl" \| "pt" \| "de" \| "hu" \| "it" \| "fr" \| "ja" \| "pl" \| "tr" \| undefined` | Nej | "en" | Den locale, der skal bruges til alle Elements. Styrer sproget og formateringen af tekst, datoer og tal. |
| `environment` | [`WhopElementsEnvironment`](https://docs.whop.com/da/sdk/elements/types#whopelementsenvironment) \| undefined | Nej | "production" | Det miljø, der skal bruges til API-kald. Brug '"sandbox"' til test uden at påvirke produktionsdata. |

## Hændelser

Hændelser, der udsendes af WhopElements.

Lyt efter disse hændelser med metoden `on()`.

### `optionsUpdated`

Udsendes, når WhopElements-indstillingerne opdateres via `updateOptions()`.

**Callback-signatur:** (options: [`WhopElementsOptions`](https://docs.whop.com/da/sdk/elements/types#whopelementsoptions)) => void

## Metoder

### `createChatSession(options)`

Opret en ny chatsession til administration af chatelementer.

| Parameter | Type | Beskrivelse |
| - | - | - |
| `options` | `ChatSessionOptions` | Konfigurationsindstillinger for chatsessionen |

**Returnerer:** [`ChatSession`](https://docs.whop.com/da/sdk/elements/chat-session)

### `updateOptions(options)`

Opdater WhopElements-konfigurationen efter initialisering.

Ændringer videreføres til alle aktive sessioner og elementer.
Kun de angivne indstillinger opdateres; andre forbliver uændrede.

| Parameter | Type | Beskrivelse |
| - | - | - |
| `options` | Partial\<[`WhopElementsOptions`](https://docs.whop.com/da/sdk/elements/types#whopelementsoptions)> | Delvist options-objekt med de værdier, der skal opdateres |

## Relaterede typer

* [WhopElementsOptions](https://docs.whop.com/da/sdk/elements/types.md#whopelementsoptions)
* [WhopElementsEnvironment](https://docs.whop.com/da/sdk/elements/types.md#whopelementsenvironment)
* [Appearance](https://docs.whop.com/da/sdk/elements/types.md#appearance)
* [Theme](https://docs.whop.com/da/sdk/elements/types.md#theme)
* [AccentColor](https://docs.whop.com/da/sdk/elements/types.md#accentcolor)


## Related topics

- [Kom godt i gang med Elements](https://docs.whop.com/da/elements/latest/getting-started.md)
- [Element Sessions (forældet)](https://docs.whop.com/da/sdk/elements/overview.md)
- [ListElement](https://docs.whop.com/da/elements/latest/wallet/balances-list.md)
