> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/chat/example-minimal-chat.md).

# Example: Minimal chat app

A **complete walkthrough** for a minimal 1:1 chat: connect, load history, send text, receive live messages, and handle disconnect. Language pages contain full runnable code.

***

## What you will build

```
  Terminal / browser tab A (alice)          Terminal / browser tab B (bob)
         │                                           │
         │  fetchChatHistory on start                │
         │  send text on Enter                       │
         ├──────────────────────────────────────────►│
         │                                           │
         │◄──────────────────────────────────────────┤
         │         live + history in onMessage        │
```

***

## Features covered

| Step                     | API                                |
| ------------------------ | ---------------------------------- |
| Authenticate and connect | `connect()`                        |
| Load thread              | `fetchChatHistory()`               |
| Send message             | `send({ data: { type: "text" } })` |
| Receive live             | `onMessage`                        |
| Persist messages         | `saveHistory: true` (default)      |
| Disconnect handling      | `onDisconnected`                   |

***

## Prerequisites

* DNotifier app with `appId` and `secret`
* SDK installed — [Installation](https://github.com/smartguy6666/dnotifier-sdk/blob/main/docs/chat/getting-started/installation/README.md)
* Two user IDs for testing (e.g. `user-alice`, `user-bob`)

***

## Test plan

1. Start **bob** listener (language page)
2. Start **alice** client in a second process
3. Alice sends a message → bob's console shows it live
4. Restart alice → `fetchChatHistory` loads prior messages
5. Disconnect network → verify offline banner / error handling

***

## Language guides

| Language                | Guide                                                                                        |
| ----------------------- | -------------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/chat/example-minimal-chat/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/chat/example-minimal-chat/dart-flutter.md)                   |

***

## Next steps

* [Chat UI patterns](/product-docs/chat/ui-patterns.md) — production UI
* [Structured payloads](https://github.com/smartguy6666/dnotifier-sdk/blob/main/docs/chat/realtime-communication/structured-payloads/README.md) — images and files
* [1:1 chat example](https://github.com/smartguy6666/dnotifier-sdk/blob/main/docs/chat/examples/one-to-one-chat/README.md) — extended example in Examples section
