Skip to main content

JavaScript examples

JavaScript examples are in contentauth/c2pa-js-examples. The examples are mirrored from the examples directory in the contentauth/c2pa-js repository.

note

As noted in the overview, the JavaScript library uses a number of modern JavaScript technologies such as WebAssembly (Wasm) and Web Workers. To understand the JavaScript examples, you should be familiar with these technologies, TypeScript and at least one bundler tool such as Webpack, Rollup, or Vite.

Additionally, the JavaScript examples use TypeScript for type safety.

Examples

ExampleToolingUI frameworkNotes
esm-importsNoneNoneThe simplest example using vanilla JavaScript (ECMAScript).
minimal-ts-webpackWebpackNoneUses TypeScript.
minimal-ts-rollupRollupNoneUses TypeScript.
minimal-ts-viteViteNoneUses TypeScript.
Includes multiple examples; see below.
react-ts-viteViteReactUses TypeScript.

Minimal-ts-vite examples

The minimal-ts-vite example directory contains these examples:

  • active-manifest: Displays a simple table with info on the active manifest.
  • cdn: Illustrates loading the JavaScript library from a content delivery network (CDN).
  • check-provenance: Illustrates how to determine whether asset files have provenance.
  • quick-start: Dumps the manifest store and active manifest to the JavaScript developer console.
  • web-components: Displays a test image with the Content Credentials pin, using c2pa-wc