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

# Het kanaallijstelement insluiten

> Toon de directe gesprekken van een gebruiker naast het chat-element en open het gesprek dat de gebruiker selecteert.

Het DM-lijstelement geeft een navigeerbare lijst weer van de directe gesprekken van de gebruiker. Het gebruikt hetzelfde [thema](https://docs.whop.com/nl/developer/guides/chat/theming-and-styles.md) als de rest van je chatelementen. Zie de [`DmsListElement`-referentie](https://docs.whop.com/nl/sdk/elements/dms-list-element) voor alle opties op het web.

### Basisgebruik

Mount de DM-lijst en luister naar events voor kanaalselectie om gebruikers naar een gesprek te leiden.

> [tab] React
>
> ```tsx theme={null}
> "use client";
>
> import { useCallback, useMemo, useState } from "react";
> import {
> 	ChatSession,
> 	DmsListElement,
> 	Elements,
> } from "@whop/embedded-components-react-js";
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
> import type {
> 	DmsListElementEvent,
> 	DmsListElementOptions,
> } from "@whop/embedded-components-vanilla-js/types";
>
> const elements = loadWhopElements();
>
> async function getToken() {
> 	const response = await fetch("/api/token");
> 	const data = await response.json();
> 	return data.token;
> }
>
> export function MessagesPage() {
> 	const [channelId, setChannelId] = useState<string>();
>
> 	const handleDmsEvent = useCallback((event: DmsListElementEvent) => {
> 		switch (event.type) {
> 			case "channelSelected":
> 				setChannelId(event.detail.id);
> 				break;
> 		}
> 	}, []);
>
> 	const dmsOptions: DmsListElementOptions = useMemo(() => {
> 		return {
> 			selectedChannel: channelId,
> 			onEvent: handleDmsEvent,
> 		};
> 	}, [channelId, handleDmsEvent]);
>
> 	return (
> 		<Elements elements={elements}>
> 			<ChatSession token={getToken}>
> 				<DmsListElement options={dmsOptions} />
> 			</ChatSession>
> 		</Elements>
> 	);
> }
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> import { loadWhopElements } from "@whop/embedded-components-vanilla-js";
>
> async function getToken() {
> 	const response = await fetch("/api/token");
> 	const data = await response.json();
> 	return data.token;
> }
>
> const whopElements = await loadWhopElements();
>
> const session = whopElements.createChatSession({
> 	token: getToken,
> });
>
> const dmsListElement = session.createElement("dms-list-element", {});
>
> dmsListElement.on("channelSelected", (ev) => {
> 	console.log("Channel selected:", ev.detail.id);
> });
>
> dmsListElement.mount("#dms-list-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> struct MessagesView: View {
>     @State private var selectedChannel: DMChannel?
>
>     var body: some View {
>         WhopDMsListView(
>             onEvent: { event in
>                 switch event {
>                 case let .channelSelected(channel):
>                     selectedChannel = channel
>                 }
>             }
>         )
>         .navigationDestination(item: $selectedChannel) { channel in
>             WhopChatView(
>                 channelId: channel.id,
>                 style: .imessage
>             )
>             .navigationBarTitleDisplayMode(.inline)
>             .navigationTitle(channel.name)
>         }
>     }
> }
> ```

### Beperken tot een account

Filter de DM-lijst zodat alleen gesprekken van een specifiek account worden getoond door een `companyId` mee te geven. Om vanaf je server een DM aan te maken, roep je [Create Channel](https://docs.whop.com/nl/api-reference/channels/create-channel.md) aan met `kind` ingesteld op `private`. Geef dezelfde account-ID mee als `account_id`, zodat de DM in de beperkte lijst verschijnt.

> [tab] React
>
> ```tsx theme={null}
> const dmsOptions: DmsListElementOptions = useMemo(() => {
> 	return {
> 		companyId: "biz_xxxx",
> 		selectedChannel: channelId,
> 		onEvent: handleDmsEvent,
> 	};
> }, [channelId, handleDmsEvent]);
>
> return (
> 	<Elements elements={elements}>
> 		<ChatSession token={getToken}>
> 			<DmsListElement options={dmsOptions} />
> 		</ChatSession>
> 	</Elements>
> );
> ```

> [tab] Vanilla JS
>
> ```typescript theme={null}
> const dmsListElement = session.createElement("dms-list-element", {
> 	companyId: "biz_xxxx",
> });
>
> dmsListElement.mount("#dms-list-container");
> ```

> [tab] Swift
>
> ```swift theme={null}
> WhopDMsListView(
>     companyId: "biz_xxxx",
>     onEvent: { event in
>         switch event {
>         case let .channelSelected(channel):
>             selectedChannel = channel
>         }
>     }
> )
> ```

### Events afhandelen

Luister naar de selectie van een kanaal om de bijbehorende chatweergave te openen.

> [tab] React
>
> | Event | Detail | Beschrijving |
> | - | - | - |
> | `channelSelected` | `{ id: string }` | Verstuurd wanneer de gebruiker een kanaal selecteert |
>
> ```tsx theme={null}
> const handleDmsEvent = useCallback((event: DmsListElementEvent) => {
> 	switch (event.type) {
> 		case "channelSelected":
> 			setChannelId(event.detail.id);
> 			break;
> 	}
> }, []);
> ```

> [tab] Vanilla JS
>
> | Event | Detail | Beschrijving |
> | - | - | - |
> | `channelSelected` | `{ id: string }` | Verstuurd wanneer de gebruiker een kanaal selecteert |
>
> ```typescript theme={null}
> dmsListElement.on("channelSelected", (ev) => {
> 	console.log("Channel selected:", ev.detail.id);
> });
> ```

> [tab] Swift
>
> | Event | Detail | Beschrijving |
> | - | - | - |
> | `.channelSelected` | `channel: DMChannel` | Verstuurd wanneer de gebruiker op een kanaal tikt |
>
> ```swift theme={null}
> WhopDMsListView(
>     onEvent: { event in
>         switch event {
>         case let .channelSelected(channel):
>             selectedChannel = channel
>         }
>     }
> )
> .navigationDestination(item: $selectedChannel) { channel in
>     WhopChatView(
>         channelId: channel.id,
>         style: .imessage
>     )
>     .navigationBarTitleDisplayMode(.inline)
>     .navigationTitle(channel.name)
> }
> ```


## Related topics

- [Een checkout insluiten](https://docs.whop.com/nl/developer/guides/embed-checkout.md)
- [Wat je kunt bouwen met Whop](https://docs.whop.com/nl/developer/start.md)
- [Uitbetalingen & geldbewegingen](https://docs.whop.com/nl/developer/payouts/overview.md)
