Skip to main content

JavaScript library

Overview

The c2pa-js repository is a monorepo containing JavaScript libraries and tools for working with C2PA metadata. It provides several libraries published for production use.

These libraries are of primary interest to developers:

  • c2pa-web: Library for C2PA metadata in the browser. Import and use this package in browser client JavaScript code.
  • c2pa-node: Node.js library that can read and validate C2PA manifest data that is attached to media assets and add signed manifests to media assets.

Additionally, the repo contains these intermediate and internal libraries:

  • c2pa-wasm: WebAssembly bindings for c2pa-rs that power c2pa-web, built with wasm-bindgen. Most applications should use c2pa-web instead of calling the bindings directly.
  • c2pa-types: TypeScript types generated from c2pa-rs structs for use by c2pa-web and c2pa-node.
note

In June 2026, the c2pa-node-v2 repo was merged into the c2pa-js repo. The old c2pa-js repository is now in c2pa-js-legacy and is deprecated. If you need to work with C2PA metadata in the browser, use the libraries in this repository instead.

Learning videos

For video walkthroughs on using the JavaScript SDK, see the following lessons from the Content Credentials Foundations course:

Using this monorepo

This monorepo uses Nx and pnpm.

Prerequisites

Install the following before you work in this repository.

Node.js

Node.js v22.22.0 or later is required. Older versions may fail to build because of unrecognized file extensions.

If you use nvm, install a supported v22 release (for example, nvm install 22.22.0).

pnpm and Nx

Install pnpm and the Nx CLI globally:

npm install -g pnpm
npm install -g nx

Rust toolchain for building c2pa-wasm

To build from source instead of using published packages only, you need the Rust toolchain and other prerequisites. See Prerequisites in packages/c2pa-wasm/README.md.

  1. Install Node.js, pnpm, and the Nx CLI (see the previous sections).
  2. Install the Rust toolchain and c2pa-wasm prerequisites (packages/c2pa-wasm/README.md).
  3. From the repository root, run pnpm install to install dependencies.

Running commands with Nx

Run tasks as nx <target> <project>. For example:

nx build c2pa-web   # Builds c2pa-web and its dependencies
nx test c2pa-web # Builds and runs tests for c2pa-web
nx lint c2pa-web # Runs ESLint on c2pa-web
nx lint c2pa-web --fix # Runs ESLint and applies fixes

Committing changes for a release

Include a changeset when your change should ship in a release.

From the repository root:

pnpm changeset

Follow the prompts to bump affected packages. The command adds a Markdown file under .changeset/; commit that file with your pull request.

After the pull request merges to main, the changeset bot opens a release pull request. When that pull request merges, a new release is published.

Directory layout

Packages

The /packages directory contains libraries published for production use.

PackageDescriptionSource
c2pa-webJavaScript library for working with C2PA data in a web browser.packages/c2pa-web
c2pa-nodeNode.js library that can read and validate C2PA manifest data that is attached to media assets and add signed manifests to media assets.packages/c2pa-node
c2pa-wasmWebAssembly bindings for c2pa-rs that power power c2pa-web, built with wasm-bindgen. Most applications should use c2pa-web instead of calling the bindings directly.packages/c2pa-wasm
c2pa-typesTypeScript types generated from c2pa-rs structs for use by c2pa-web.packages/c2pa-types

Tools

The /tools directory contains utilities for local development.

testbed

Minimal site for inspecting c2pa-web output and experimenting locally. Source: tools/testbed.

nx-wasm-bindgen

Custom Nx executor that builds c2pa-wasm with wasm-bindgen. Source: tools/nx-wasm-bindgen.

License

This project is licensed under the MIT license.