You must install Node.js for package management and TypeScript compilation.
To install Node.js on macOS:
- Install Homebrew: The easiest way to install Node.js on your macOS system is by using Homebrew. Follow the instructions on the Homebrew page to install it.
- Install Node.js: Once you have installed Homebrew, open a terminal and enter this command:
brew install node@16
Using a CDN
The quickest way to get up and running is to use a CDN such as jsDelivr. One of the big advantages of using a CDN is that it provides all the required static assets, so you don't have to host them. The CDN also delivers the files at the edge, which enables faster downloads to your users.
Static assets include the following, as seen in the config passed to
The version numbers provided in the CDN URLs must match in all of the places you reference the library. To make it easy, use a variable that provides the version as shown in the example.
Using a package manager
You can also bring in the library with a package manager, such as
yarn. This way, all of the client side code is hosted with your app and there are no external dependencies. For example, using
npm install c2pa
When loading via a package manager, the library needs access to two externally-hosted assets so it can "lazy load" them:
c2pa/dist/assets/wasm/toolkit_bg.wasm- the WebAssembly binary
c2pa/dist/c2pa.worker.min.js- the Web Worker script
Be sure to configure your server to send proper
Content-Type headers for these files. For more information, see Hosting.
Examples for common build systems are shown below. They are also available in the c2pa-js-examples repository.