Skip to content
AI-Ready Docs
/llms.txt/llms-mcp.txt

Embedding & Self-Hosting ​

BaroCSS CAD ships as a 100% static client-side bundle — no backend geometry servers, no database migrations, and no WebAssembly build quirks. You can embed interactive 3D CAD directly inside documentation, product configurators, or internal portals, or deploy the entire unified site on any static host.

1. Unified Static Build (pnpm build:site) ​

Running pnpm build:site executes scripts/build-static-site.mjs and assembles a single static directory (dist-site/):

RouteSource AppRole
/apps/library-docsProduct showcase, documentation, 77 /how/ visualizers, Live TS Playground
/app/apps/cad-studioFull 5-Workspace CAD Studio + ?embed=1 Quick-Fit mode
/review/apps/cad-viewerShareable BaroCSS Review (.bcad 3D/2D diff + automatic 2D HLR fallback)
/llms*.txtgenerate-llms.mjsAI-Ready context indexes (llms.txt, llms-sdk.txt, llms-mcp.txt, llms-full.txt)

Root Domain vs Subpath Hosting (SITE_BASE) ​

bash
# Custom root domain (official site: https://cad.barocss.com/)
pnpm build:library
pnpm build:site            # writes dist-site/CNAME = cad.barocss.com
SITE_CNAME=cad.example.com pnpm build:site   # self-hosted custom domain
SITE_CNAME= pnpm build:site                  # skip the CNAME file

# Subpath hosting (e.g. https://barocss.github.io/cad/)
SITE_BASE=/cad/ SITE_ORIGIN=https://barocss.github.io pnpm build:site

build-static-site.mjs automatically configures:

  • VitePress base and sitemap/OpenGraph URLs
  • cad-studio VITE_BASE (/app/ or /cad/app/)
  • Base-prefixed dist-site/llms.txt links (without mutating repo-tracked docs/public/llms.txt)
  • _headers with strict frame-ancestors CSP and immutable asset caching for Cloudflare Pages / Netlify

Static Host Recipes ​

  • GitHub Pages: Already automated via .github/workflows/deploy-site.yml (actions/configure-pages@v5 automatically injects SITE_BASE and SITE_ORIGIN). Enable Settings → Pages → Source: GitHub Actions.
  • Cloudflare Pages / Netlify: Set build command to pnpm build:library && pnpm build:site and output directory to dist-site.
  • Vercel: Set build command to pnpm build:library && pnpm build:site and output directory to dist-site.

2. Embedding Quick-Fit Studio (?embed=1) ​

Embed a live, interactive parametric part configurator in any webpage with a single <iframe>:

html
<iframe
  src="https://cad.barocss.com/app/?mode=quickfit&preset=nema17&embed=1&chrome=minimal"
  title="BaroCSS CAD Live Quick-Fit"
  style="width: 100%; height: 480px; border: 0; border-radius: 12px;"
  allow="webgpu; clipboard-write"
></iframe>

Supported Query Parameters ​

ParameterValuesBehavior
embed1 | trueEnables embed mode: hides top navigation chrome and uses an ephemeral session so embedded previews never overwrite a visitor's saved Studio workspace
modequickfitOpens directly in Quick-Fit parametric slider mode
presetnema17 | enclosure | adapterLoads a built-in parametric B-Rep preset
chromenone | minimalminimal shows the Quick-Fit parameter panel and Open in Studio ↗ handoff button; none renders a pure 3D canvas
themedark | lightMatches host page appearance
rendererauto | webgl2Forces WebGL2 when WebGPU is unavailable (recommended fallback after probing navigator.gpu?.requestAdapter())

3. Controlling the Embed via postMessage (barocss-embed-v1) ​

The Studio iframe exposes a typed, origin-checked postMessage bridge on channel 'barocss-embed-v1':

Messages Sent by Studio → Host ​

ts
type EmbedChildToHost =
  | { channel: 'barocss-embed-v1'; type: 'ready'; renderer: 'webgpu' | 'webgl2'; preset: string }
  | {
      channel: 'barocss-embed-v1';
      type: 'metrics';
      volumeMm3: number | null;
      massG: number | null;
      boundsMm: [number, number, number] | null;
      health: 'healthy' | 'warning' | 'error';
      parameters: Record<string, number>;
    }
  | { channel: 'barocss-embed-v1'; type: 'error'; code: string; message: string };

Messages Sent by Host → Studio ​

ts
const frame = document.querySelector<HTMLIFrameElement>('#cad-embed');

// Switch parametric preset live without reloading the iframe
frame?.contentWindow?.postMessage(
  { channel: 'barocss-embed-v1', type: 'setPreset', preset: 'enclosure' },
  '*',
);

// Update a single named parameter deterministically
frame?.contentWindow?.postMessage(
  { channel: 'barocss-embed-v1', type: 'setParam', name: 'thickness', value: 8 },
  '*',
);

// Reframe the 3D camera
frame?.contentWindow?.postMessage(
  { channel: 'barocss-embed-v1', type: 'fitCamera' },
  '*',
);

Incoming host messages are validated against isAllowedEmbedOrigin (same-origin, localhost / 127.0.0.1, barocss.dev, barocss.com (incl. cad.barocss.com), *.pages.dev, *.vercel.app). When self-hosting on a custom domain, keep the embed on the same origin (/app/ alongside /) so origin validation passes automatically with zero CORS or cross-origin friction.

4. Embedding BaroCSS Review (/review/?embed=1) ​

To embed an interactive .bcad pull-request review with Before/After geometry diffs, approval evidence, and Quick-Fit sliders:

html
<iframe
  src="https://cad.barocss.com/review/?embed=1"
  title="BaroCSS Review Live Demo"
  style="width: 100%; height: 480px; border: 0; border-radius: 12px;"
  allow="webgpu"
></iframe>

On browsers without WebGPU (Firefox, Safari, VMs, headless environments), BaroCSS Review automatically switches to interactive 2D HLR projection fallback (Iso | Front | Top | Right | 4-View + clickable edges/faces) so proposal diffs and spec verification remain 100% functional.