C3 AI Documentation Home

Bundle and Serve

This page turns your source into the static files the C3 Agentic AI Platform serves and configures serving so clean paths work. You confirm the build setting, build the bundle, enable single-page-application serving, and verify the result. When you finish, ui/content holds a built bundle that the C3 Agentic AI Platform serves at the application root.

Before you begin

Have the application building and running locally, from The Local Dev Loop.

Step 1: Confirm the relative base

Confirm the Vite configuration sets base: './', so the bundle references its assets by relative path. This is required because the C3 Agentic AI Platform serves the application under a path prefix rather than at the domain root, and absolute asset paths would resolve to the wrong place.

TypeScript
// vite.config.ts
export default defineConfig({ base: './', build: { outDir: 'content', emptyOutDir: true } })

End state: the build uses a relative base and outputs to ui/content.

Step 2: Build the bundle

From the ui/ directory, build the application:

Command Line
cd ui
npm run build

The build writes a static bundle into ui/content, ending with a summary and no errors.

End state: ui/content holds a built index.html and the JavaScript and CSS assets.

Step 3: Enable single-page-application serving

Enable single-page-application serving with a small configuration file in the package, so the C3 Agentic AI Platform serves your application at a clean root and for path routes rather than redirecting to the console:

JSON
// config/UiService.Config/DEFAULT.json
{ "name": "DEFAULT", "spaMode": true }

With spaMode on, the server falls back to serving index.html for an unmatched path. The configuration is read from the package at provision time, so a change takes effect on the next deploy rather than at runtime.

End state: the package contains a UiService.Config with spaMode on.

Step 4: Choose the routing style

Choose how the application routes, because the two styles behave differently under the C3 Agentic AI Platform's serving. Path routing uses clean URLs and requires spaMode from the previous step. Hash routing puts the route after a #, which the server never sees, so it needs no configuration and works as a fallback.

End state: the application uses path routing with spaMode, or hash routing with no configuration.

Step 5: Confirm serving

After the application is deployed, open the application root and confirm the single-page application loads there and that a path route resolves rather than redirecting to the console. Deploy to an Environment covers the deploy that makes the bundle reachable.

End state: the application root and its path routes serve the application.

What you have now

You have a built bundle in ui/content and the serving configuration that makes it load at a clean root. Next, put it on a running environment in Deploy to an Environment.

Reference: where bundling happens

Bundling can happen in three places, and knowing all three lets you place any application you encounter. Committing the prebuilt bundle, which the worked application does, builds locally and commits the ui/content output for the C3 Agentic AI Platform to serve as-is. The server-side bundler compiles the application at provision time, which is the path for the older component-library applications. The in-pipeline build compiles the application as a continuous-integration (CI) step configured through the package. The intended direction is the in-pipeline CI build, with the committed bundle as the current workaround.

Reference: several applications under one base URL

Serving several compiled applications under one base URL is a C3 Agentic AI Platform serving concern, not a React one, documented with the UiService configuration rather than here. The mechanism is named UiService configurations plus spaMode.

Decisions on this page

The bundling mechanism and the routing style are the two choices.

DecisionOptionsRecommendation
Bundling mechanisma committed bundle, the server-side bundler, or the in-pipeline CI buildCommitted today; the in-pipeline CI build is the intended direction
Routinghash routing with no configuration, or path routing with spaModePath routing with spaMode for clean paths; hash routing as the no-configuration fallback

See also

Was this page helpful?