> ## 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.

# Element Sessions 시작하기

> 레거시 @whop/embedded-components 패키지를 설정합니다. 새로운 채팅 통합에는 @whop/elements를 사용하세요.

## 개요

Whop 임베디드 컴포넌트의 기본 진입점입니다.

WhopElements는 구성을 관리하고 채팅 세션을 생성하는 루트 객체입니다.
한 번 초기화한 후 이를 사용해 채팅, DM, 검색 요소를 마운트하는
세션을 생성하세요.

## 설치

```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
```

## 예제

### 기본 초기화

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

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

### 채팅 세션 생성하기

```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");
```

### 초기화 후 옵션 업데이트하기

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

### 옵션 변경 수신하기

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

## 옵션

| 속성 | 타입 | 필수 | 기본값 | 설명 |
| - | - | - | - | - |
| `appearance` | [`Appearance`](https://docs.whop.com/ko/sdk/elements/types#appearance) \| undefined | 아니요 | - | Whop 임베디드 Elements의 모양을 사용자 지정합니다. 라이트/다크 모드, 강조 색상 등의 테마 설정이 포함됩니다. |
| `locale` | `"en" \| "es" \| "zh" \| "nl" \| "pt" \| "de" \| "hu" \| "it" \| "fr" \| "ja" \| "pl" \| "tr" \| undefined` | 아니요 | "en" | 모든 Elements에 사용할 로캘입니다. 텍스트, 날짜, 숫자의 언어와 형식을 제어합니다. |
| `environment` | [`WhopElementsEnvironment`](https://docs.whop.com/ko/sdk/elements/types#whopelementsenvironment) \| undefined | 아니요 | "production" | API 호출에 사용할 환경입니다. 프로덕션 데이터에 영향을 주지 않고 테스트하려면 '"sandbox"'를 사용하세요. |

## 이벤트

WhopElements가 발생시키는 이벤트입니다.

`on()` 메서드를 사용하여 이 이벤트를 수신할 수 있습니다.

### `optionsUpdated`

`updateOptions()`를 통해 WhopElements 옵션이 업데이트되면 발생합니다.

**콜백 시그니처:** (options: [`WhopElementsOptions`](https://docs.whop.com/ko/sdk/elements/types#whopelementsoptions)) => void

## 메서드

### `createChatSession(options)`

채팅 요소를 관리하기 위한 새 채팅 세션을 생성합니다.

| 매개변수 | 타입 | 설명 |
| - | - | - |
| `options` | `ChatSessionOptions` | 채팅 세션의 구성 옵션 |

**반환값:** [`ChatSession`](https://docs.whop.com/ko/sdk/elements/chat-session)

### `updateOptions(options)`

초기화 후 WhopElements 구성을 업데이트합니다.

변경 사항은 모든 활성 세션과 요소에 전파됩니다.
제공된 옵션만 업데이트되며, 나머지는 변경되지 않습니다.

| 매개변수 | 타입 | 설명 |
| - | - | - |
| `options` | Partial\<[`WhopElementsOptions`](https://docs.whop.com/ko/sdk/elements/types#whopelementsoptions)> | 업데이트할 값이 담긴 부분 옵션 객체 |

## 관련 타입

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


## Related topics

- [Elements 시작하기](https://docs.whop.com/ko/elements/latest/getting-started.md)
- [블루프린트로 프로젝트 시작하기](https://docs.whop.com/ko/developer/guides/blueprints.md)
- [인증 업데이트 또는 삭제](https://docs.whop.com/ko/developer/verification/manage.md)
