Skip to main content

Machine Views

Render server-driven UI for project machines (daily streaks, loyalty walls, etc.) inside a sandboxed iframe.

Prebuilt Components

All components must be rendered inside a HyveSdkProvider.

import {
MachineView,
MachineViewButton,
MachineViewImageButton,
MachineViewFullscreen,
} from "@hyve-sdk/js/react";

MachineView

Inline iframe — fits wherever you place it.

<MachineView machineId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
PropTypeRequiredDescription
machineIdstringYesMachine UUID to fetch and render
classNamestringNoClass on the iframe
styleCSSPropertiesNoInline styles on the iframe

Renders null while loading or on error.


MachineViewButton

A button that opens the machine in a centered modal dialog.

<MachineViewButton machineId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
PropTypeRequiredDefaultDescription
machineIdstringYesMachine UUID
childrenReactNodeNo"Open"Button label
titlestringNoDialog header title
dialogWidthnumber | stringNo520Dialog panel width
viewHeightnumber | stringNo400iframe height inside dialog
classNamestringNoClass on the trigger button
styleCSSPropertiesNoStyles on the trigger button

Closes on backdrop click or Escape key.


MachineViewImageButton

An image that opens the machine in a modal dialog.

<MachineViewImageButton
machineId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
src="/icons/streak.png"
/>
PropTypeRequiredDefaultDescription
machineIdstringYesMachine UUID
srcstringYesImage URL
altstringNo""Image alt text
titlestringNoDialog header title
dialogWidthnumber | stringNo520Dialog panel width
viewHeightnumber | stringNo400iframe height inside dialog
imgStyleCSSPropertiesNoStyles on the <img> element
classNamestringNoClass on the trigger button
styleCSSPropertiesNoStyles on the trigger button

MachineViewFullscreen

Takes over the full viewport. Mount to show, unmount to hide. Locks body scroll on iOS Safari.

{
showStreak && (
<MachineViewFullscreen machineId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
);
}
PropTypeRequiredDescription
machineIdstringYesMachine UUID
titlestringNoTitle in the top bar
onClose() => voidNoCalled on close button or Escape key

Custom Machine View

Note: Prefer the prebuilt components above. Use getMachineRender only when you need full control over how the snippet is injected or rendered.

getMachineRender

Fetches the JavaScript render for a machine by ID. All prebuilt components use this internally.

const js = await hyve.getMachineRender("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");

Returns a Promise<string> — a JS snippet ready for injection into a page.

The returned snippet is an IIFE that receives a container element and renders UI into it:

(function(c) {
var panel = document.createElement('div');
// ... builds and styles the UI ...
c.appendChild(panel);
})(container);