Use libraries from the npm ecosystem
The C3 Agentic AI Platform allows you to use libraries from the npm ecosystem, but the platform enforces a different workflow than a typical Node.js project. Instead of using package.json or running npm install, the platform requires you to declare libraries in a shared, version-locked runtime named js-webpack_c3.
This runtime controls all frontend dependencies, including those for custom React components. You must declare each dependency in this runtime and resolve it using the C3 AI Console.
Do not run npm install. Do not create a local package.json. The platform controls all dependency resolution centrally.
Use platform-provided core libraries
The platform automatically includes these core libraries:
- Node.js
- React
- Redux
The runtime already contains these libraries. Do not redeclare them. If you redeclare them, the platform may throw runtime errors or load conflicting versions.
Understand how the platform runtime works
The js-webpack_c3 runtime replaces the standard Node.js dependency mechanism. The table below maps traditional concepts to platform equivalents:
| Node.js concept | C3 AI Platform equivalent |
|---|---|
package.json | Declares runtime dependencies |
package-lock.json | Locks exact versions during runtime resolution |
npm install | Resolves and locks libraries using console methods |
node_modules/ | Platform manages code distribution internally |
| Console commands | Upserts and resolves declared libraries |
| Metadata output | Stores version-locked runtime and dependency graph |
To declare libraries, create or edit the file:
{package}/metadata/ImplLanguage.Runtime/js-webpack_c3.jsonDeclare the libraries, then use the C3 AI Console commands under "Step 3: Resolve the runtime". These commands write the resolved runtime state to:
{package}/metadata/ImplLanguage.Runtime/
{package}/metadata/Js.Runtime/Every component that references js-webpack_c3 loads libraries only from the resolved runtime. The platform enforces exact version matches and ensures consistent builds across teams and environments.
To understand how the runtime system supports platform-wide resolution, read Understanding Action Engines.
Add a new npm library
Use the steps below to add Material UI to your runtime.
Step 1: List installed libraries
Run the following command in the C3 AI Console:
ImplLanguage.Runtime.forName("js-webpack_c3").librariesThe console prints all installed libraries and their locked versions. Check this list before you add a new dependency.
Step 2: Edit the runtime definition
If the runtime file exists:
Open the file:
Text{package}/metadata/ImplLanguage.Runtime/js-webpack_c3.jsonAdd the packages:
JSON{ "name": "js-webpack_c3", "libraries": [ "npm @mui/material@5.14.0", "npm @emotion/react@11.11.1", "npm @emotion/styled@11.11.0" ] }
If the runtime file does not exist:
Create the file at the path above.
Add a basic definition:
JSON{ "name": "js-webpack_c3", "libraries": [] }Run the resolution commands (see Step 3) to initialize the metadata.
Reopen the file and declare the libraries you want.
Step 3: Resolve the runtime
Run the following commands in the C3 AI Console:
var runtime = ImplLanguage.Runtime.forName("js-webpack_c3");
Pkg.setDevMode(true);
Js.upsertRuntime(runtime, "client");These commands register the runtime, download all dependencies, lock their versions, and write the metadata to your package.
Step 4: Import and use the libraries
Once you resolve the runtime, import libraries into your component:
// {package}/ui/c3/src/customInstances/MyComponent.tsx
import Button from '@mui/material/Button';
const MyComponent = () => {
return <Button variant="contained">Hello world</Button>;
};Use SDL or route configuration to render your component in the UI.