Niche Portobello Mushroom


    0.3.0 • Public • Published


    All the things a panda needs (for JavaScript)

    This library provides all tools required to write a client for the p2panda network. It is shipped both as a Rust crate p2panda-rs with WebAssembly bindings and a NPM package p2panda-js with TypeScript definitions running in NodeJS or any modern web browser.


    To install p2panda-js from the NPM package, run:

    npm i p2panda-js


    import { createKeyPair, Session } from 'p2panda-js';
    // This example uses the "chat" schema at which this hash is pointing. We are
    // still working on a good way for you to create and access data schemas. For
    // now you can use to do so
    const CHAT_SCHEMA = '00200cf84048b0798942deba7b1b9fcd77ca72876643bd3fedfe612d4c6fb60436be';
    // Create a key pair for every usage context of p2panda, i.e. every device and
    // every piece of software that is used. Key pairs should never have to be
    // transferred between different devices of a user
    const keyPair = await createKeyPair();
    // Open a long running connection to a p2panda node and configure it so all
    // calls in this session are executed using that key pair
    const session = new Session('').setKeyPair(keyPair);
    // Compose your operation payload, according to chosen schema
    const payload = {
      operation: 'Hi there',
    // Send new chat operation to the node
    await session.create(payload, { schema: CHAT_SCHEMA });
    // Query instances from the p2panda node
    const instances = await session.query({ schema: CHAT_SCHEMA });
    // -> 'Hi there'

    Development Setup


    In order to develop with the current code base p2panda-js needs to be compiled from the p2panda-rs code using wasm-pack. This requires a working Rust environment to be setup and wasm-pack to be installed. You can then run the following commands, the compilation occurs during the testing and build phases.

    # Install dependencies
    npm install
    # Check code formatting
    npm run lint
    # Run tests
    npm test
    # Compile wasm and bundle js package
    npm run build

    Debug logging

    Enable debug logging for node environments by setting an environment variable:

    export DEBUG='p2panda*'

    Enable debug logging from a browser console by storing a key debug in local storage:

    localStorage.debug = 'p2panda*';


    GNU Affero General Public License v3.0 AGPL-3.0-or-later

    Supported by

    This project has received funding from the European Union’s Horizon 2020 research and innovation programme within the framework of the NGI-POINTER Project funded under grant agreement No 871528




    npm i p2panda-js

    DownloadsWeekly Downloads






    Unpacked Size

    2.65 MB

    Total Files


    Last publish


    • cafca
    • sophiiistika
    • andreasdz