Skip to main content
Hugs
@getcliqio/hug-frontend/react gives React the same answer state as mount_hug: the same starting answer, set and replace, checks, Submit label and summary. Scaffold one with:
React is compiled into the bundle like any library (React 18 or later). review-batch-react is the tutorial’s hug in React.
While @getcliqio/hug-frontend is linked from a checkout (file:) rather than installed from npm, the build can pick up two copies of React — the checkout’s and yours (“Cannot read properties of null (reading ‘useState’)”). Alias React to yours in build.mjs (alias: { react: …, 'react-dom': … }) and dedupe it in tests (resolve.dedupe), as review-batch-react does. Installed from npm, React is a peer dependency and there is one copy.

<HugRoot>

The whole page: it connects, then draws edit or view by mode, or an error panel. If drawing throws, the page shows “This hug failed to draw” with the message (and logs the error) instead of going blank, as mount_hug does; the panel clears when the mode or the answer shown changes.
src/main.tsx (abridged)

useHug

For your own layout, useHug(definition, { initial, submit, summary }) returns the state as it changes:
status is connecting, error (with error), or ready, with:

Controls

Use ordinary React controls and call set on change — this is what cliq hug new --react scaffolds:
Import @getcliqio/hug-frontend/ui for the Hub’s font and colours (--cliq-* variables) even without its elements. The UI kit’s elements are web components: in React, set their properties (.value, .choices, .ref) and listen for their change event through a ref.

<DefaultView>

<DefaultView definition state answer? /> draws an answer from the definition, as mount_hug’s default view does. answer defaults to the one the host is showing, else the viewer’s own.