LogoLoroDocsDocsBlogBlogChangelogChangelogAboutAbout
GitHubGitHub (opens in a new tab)DiscordDiscord (opens in a new tab)
  • Introduction to Loro
    • Getting Started
    • Loro Document
    • Sync
    • Text
    • Composing CRDTs
    • List and Movable List
    • Map
    • Tree
    • Counter
    • Version
    • Event Handling
    • Export Mode
    • Persistence
    • Cursor
    • Time Travel
    • What are CRDTs
    • How to Choose the Right CRDT Types
    • When Not to Rely on CRDTs
    • DocState and OpLog
    • Container ID
    • Shallow Snapshot
    • Storing Timestamps
    • Operations and Change
    • Loro's Versioning Deep Dive: DAG, Frontiers, and Version Vectors
    • Event Graph Walker
    • Undo/Redo
    • Batch Import
    • Loro Inspector
    • JS/WASM Benchmarks
    • Native Benchmarks
    • Document Size
  • Examples
Question? Give us feedback → (opens in a new tab)Edit this page
Docs
Tutorial
Counter

Counter

Loro's Counter will add up all the applied values, and supports integers and floating point numbers.

Here is how to use it:

const doc = new LoroDoc();
const counter = doc.getCounter("counter");
counter.increment(1);
counter.increment(2);
counter.decrement(1);
expect(counter.value).toBe(2);
TreeVersion
Loro 2025 ©