Preview of main at d0a501a, 2026-11-07

Use C++ from JavaScript, in the browser

webcpp compiles C++ libraries to WebAssembly with Emscripten, for a page's JavaScript to use: code that controls its own memory, in a module you download once. Some are ports of the libraries you already use, kept wire compatible with them.

What builds for the browser today

These libraries build for Emscripten, the browser's target:

  • asio

    Boost.Asio for native, browser and WASIp2/P3 targets, with explicit platform capabilities and shipped Wasm implementations.

  • beast

    Beast-compatible HTTP and WebSocket interfaces for WebAssembly and native applications.

  • cobalt

    Boost.Cobalt coroutine applications on native, browser and WASI targets.

  • config

    webcpp's configuration, which every webcpp library includes first: the target a program is built for, whether webcpp has exceptions, and webcpp's version.

  • document

    A JSON document for C++20 that behaves as JavaScript does, in one relocatable image.

  • idna

    IDNA2008 and UTS 46 for C++20: Punycode, ToASCII and ToUnicode, and label validity, over generated Unicode 17.0 tables.

  • lexical

    Validators and Boost.URL grammar rules for the string formats of JSON Schema, for C++20.

  • pratt

    A generic Pratt parser engine for C++20, with a decimal calculator built on it.

  • trystero

    Serverless WebRTC rooms for C++20, wire compatible with Trystero.

trystero's repository has a chat page whose room is C++ compiled to WebAssembly, meeting its peers over public Nostr relays.

The chat page's source

What is coming

  • trystero's JavaScript API: Trystero's own joinRoom, makeAction and onPeerJoin, backed by C++, so that a page changes only its import.
  • Trystero's own examples from trystero.dev, collaborative cursors first, running on webcpp's trystero.
  • JavaScript functions exported to C++, so that C++ drives the page.
  • Sizes, measured: each library's WebAssembly beside its JavaScript original's, raw, gzip and brotli.
  • The same code on a server: a WASI component run by wasmtime, and a native program.