Skip to main content

3. Frontend Integration: @buildcores/render-client

Install the React client:

npm install @buildcores/render-client

Peer dependencies:

react >= 16.8.0
react-dom >= 16.8.0

3.1. Authentication Setup

Configure ApiConfig to use session token auth. The frontend callback should call your backend, and your backend should call POST /auth/render-session. The client caches session tokens and refreshes them after a 401 response.

import { BuildRender, type ApiConfig } from "@buildcores/render-client";

const apiConfig: ApiConfig = {
environment: "prod",
authMode: "session",
getRenderSessionToken: async () => {
const res = await fetch("/api/buildcores-token", { method: "POST" });
if (!res.ok) {
throw new Error("Failed to mint BuildCores session token");
}
const data = await res.json();
return {
token: data.session_token,
expiresAt: data.expires_at,
};
},
};

3.2. <BuildRender /> Component

BuildRender displays a sprite-based interactive 360-degree viewer. It can render directly from part IDs or from an existing BuildCores share code.

Render by part IDs:

import { BuildRender } from "@buildcores/render-client";

<BuildRender
parts={{
parts: {
PCCase: ["qq9jamk7c"],
GPU: ["z7pyphm9k"],
Motherboard: ["iwin2u9vx"],
CPUCooler: ["62d8zelr5"],
RAM: ["dpl1iyvb5"],
},
profile: "cinematic",
}}
size={500}
apiConfig={apiConfig}
/>;

Render by share code:

<BuildRender
shareCode="abc123xyz"
size={500}
apiConfig={apiConfig}
/>;

Use shareCode when rendering an existing configured build. It preserves the build's saved interactive state, including case fan and radiator placements.

Component props:

PropTypeDefaultDescription
partsRenderBuildRequest-Parts configuration. Required unless shareCode is provided. parts.profile is where render profile is configured for parts-based renders.
shareCodestring-Share code of an existing build. Takes precedence over parts.
sizenumber300Square width and height in CSS pixels.
width / heightnumber-Override display width and height individually.
apiConfigApiConfigrequiredAuth and environment configuration.
mouseSensitivitynumber0.2Rotation sensitivity for mouse drag.
touchSensitivitynumber0.2Rotation sensitivity for touch drag.
animationMode"bounce" | "spin360""bounce"Auto-rotation animation style.
spinDurationnumber10000Duration in milliseconds for one full 360-degree rotation in spin360 mode.
interactivebooleantrueEnables drag-to-rotate and scroll-to-zoom. Set false for non-interactive showcase embeds.
zoomnumber1Client-side initial zoom level. Intended range is 0.5 to 2.5.
cameraZoomnumber1Server-side camera distance. Values are clamped from 0.5 to 2.0.
modelQuality"low" | "medium" | "high"API default3D model asset quality for server renders. Can also be supplied as parts.modelQuality.
showGridbooleanprofile-dependentShow the 3D ground grid.
sceneRenderScene-Environment scene preset.
showBackgroundboolean-Show the environment background.
winterModebooleanfalseEnable winter visual effects. Mutually exclusive with springMode.
springModebooleanfalseEnable spring visual effects. Mutually exclusive with winterMode.
cameraOffsetXnumber0Horizontal camera offset. Server clamps values from -0.3 to 0.3.
gridSettingsGridSettings-Custom grid appearance settings.
frameQuality"standard" | "high""standard"standard renders 72 frames; high renders 144 frames.
useSpriteRenderOptions.mode"async" | "experimental""async"Selects async job rendering or the legacy pregenerated endpoint.
showInteractiveConfigButtonbooleanfalseShow the embedded fan, radiator, RGB, and side-panel configuration menu for parts-based async renders.
interactiveConfigTheme"light" | "dark" | "system""system"Theme for the embedded configuration menu.
interactiveConfigPanelPosition"top-left" | "top-right" | "bottom-left" | "bottom-right""top-left"Corner where the embedded configuration menu opens.
interactiveConfigPanelHeight"compact" | "max" | number | string"max"Height for the embedded configuration menu. Numbers are treated as pixels; strings can be CSS heights.

3.3. API Functions

The package exports helper functions for direct API use:

import {
PartCategory,
getAvailableParts,
getBuildByShareCode,
getPartsByIds,
renderByShareCode,
} from "@buildcores/render-client";

const gpus = await getAvailableParts(PartCategory.GPU, apiConfig, {
limit: 20,
skip: 0,
});

console.log(gpus.data.GPU);

const build = await getBuildByShareCode("abc123xyz", apiConfig);
const parts = await getPartsByIds(["7xjqsomhr", "z7pyphm9k"], apiConfig);

const result = await renderByShareCode("abc123xyz", apiConfig, {
profile: "cinematic",
format: "sprite",
});

console.log(result.videoUrl);

Exported helpers include:

FunctionDescription
getAvailableParts(category, config, options)Fetch renderable parts for one category with pagination.
getBuildByShareCode(shareCode, config)Fetch build metadata and part IDs for an existing share code.
getPartsByIds(partIds, config)Fetch part details for up to 100 BuildCores IDs.
renderByShareCode(shareCode, config, options)Create a share-code render job and poll until a media URL is available.
createRenderByShareCodeJob(shareCode, config, options)Create a share-code render job without polling.
renderBuildExperimental(request, config)Fetch a pregenerated MP4 from the legacy cached endpoint.
renderSpriteExperimental(request, config)Fetch a pregenerated WebP sprite from the legacy cached endpoint.

3.4. Part Categories

Valid categories are:

CPU
GPU
RAM
Motherboard
PSU
Storage
PCCase
CPUCooler
CaseFan