Skip to content

twilic/examples

Repository files navigation

Twilic Examples

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.

Prerequisites

  • Node.js 24+
  • pnpm (recommended)

Setup

pnpm install

Examples

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

API response (HTTP)

# terminal 1
pnpm example:api-response

# terminal 2
pnpm example:api-response:client

WebSocket session

# size comparison (recommended first)
pnpm example:websocket:simulate

# live stream
pnpm example:websocket          # terminal 1
pnpm example:websocket:client   # terminal 2

CLI examples

pnpm example:batch-records
pnpm example:telemetry
pnpm example:logs
pnpm example:cache-payload

Goals

  • 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

When Twilic Fits Well

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.

Related resources

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Example projects showing how to use Twilic for APIs, batches, sessions, telemetry, logs, and compact binary payloads.

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors