Official example projects and real-world use cases for Twilic.
Twilic Examples is a collection of practical examples that show how Twilic can be used in real applications. The goal of this repository is to make Twilic easier to understand, evaluate, and adopt by demonstrating concrete use cases instead of only providing the specification or library API.
Twilic is especially useful when data contains repeated structures, repeated strings, homogeneous records, batched payloads, or session-based updates. These examples show how Twilic can be used as a compact binary representation for APIs, WebSocket messages, telemetry data, logs, cache payloads, and other structured data.
- Node.js 24+
- pnpm (recommended)
pnpm install| Example | Profile | Command |
|---|---|---|
| api-response | Stateless Batch | pnpm example:api-response |
| websocket-session | Stateful | pnpm example:websocket:simulate |
| batch-records | Batch | pnpm example:batch-records |
| telemetry | Batch (col_batch) |
pnpm example:telemetry |
| logs | Dynamic + Batch | pnpm example:logs |
| cache-payload | Dynamic (stateless) | pnpm example:cache-payload |
# terminal 1
pnpm example:api-response
# terminal 2
pnpm example:api-response:client# size comparison (recommended first)
pnpm example:websocket:simulate
# live stream
pnpm example:websocket # terminal 1
pnpm example:websocket:client # terminal 2pnpm example:batch-records
pnpm example:telemetry
pnpm example:logs
pnpm example:cache-payload- Show practical use cases for Twilic
- Compare Twilic with JSON and MessagePack where useful
- Provide small examples that are easy to run and modify
- Demonstrate Twilic features such as batch encoding, compact payloads, and session patches
- Help developers decide when Twilic is a good fit
Twilic is designed to work well with data that has repeated patterns. It can be a good fit when many messages share the same object shape, when the same strings appear repeatedly, when records are sent in batches, or when only small changes need to be sent after the first message.
Twilic is not intended to replace every serialization format in every situation. These examples are designed to make the trade-offs visible and help developers choose Twilic for the right use cases.
- Cookbook — practical patterns
- Playground — interactive size comparison
- Benchmark — encode/decode throughput
- @twilic/core — JavaScript SDK
This project is licensed under the MIT License - see the LICENSE file for details.