# pibblSync

```tsx
import { Rectangle } from "@pibbl/core";
import { pibblSync } from "@pibbl/core/sync";

const controller = pibblSync(
  document.querySelector("canvas")!,
  <Rectangle style={{ width: 160, height: 80, fill: "#2563eb" }} />,
);
// Later: controller.dispose();
```

The root is a [PibblNode](/reference/types/elements-components/#pibblnode), configuration
uses [PibblConfig](/reference/types/canvas-runtime/#pibblconfig), and the return value is
[PibblController](/reference/types/canvas-runtime/#pibblcontroller).

`pibblSync(canvas, root, config?): PibblController` synchronously prepares the
embedded version of the same generated layout binary and mounts or updates the
canvas. It does not fetch or wait for a Promise. Use this separate entry for
intentionally synchronous or offline hosts. The root package does not re-export
this operation or include its embedded bytes in asynchronous-only bundles.

If [prepareLayoutEngine](/reference/functions/prepare-layout-engine/) or an earlier
[pibbl](/reference/functions/pibbl/) call has prepared the compatible module, synchronous
mounting reuses it without decoding or compiling again. Compiled code is shared;
mutable layout instances and memory remain owned by their respective mounts.

Initialization and mount failures throw synchronously. An already aborted caller
throws `AbortError`. New same-canvas requests supersede older pending requests;
existing live mounts retain their stable controller and originally captured
surface/lifetime configuration. Disposing the live mount invalidates a pending
update so it cannot resurrect the released mount. Importing the sync entry alone
performs no decoding, compilation, instantiation or scheduling.

## API details from source

<span id="api-pibblSync"></span>

Mounts or updates synchronously using the embedded layout WASM binary.
Import from

```ts
pibblSync: (canvas: HTMLCanvasElement, element: PibblNode, config?: PibblConfig) => PibblController
```

Related API: [pibblSync](/reference/functions/pibbl-sync/), [PibblNode](/reference/types/elements-components/#pibblnode), [PibblConfig](/reference/types/canvas-runtime/#pibblconfig), [PibblController](/reference/types/canvas-runtime/#pibblcontroller).

### Parameters

- **`canvas`** — The HTML Canvas owned by the mount.

- **`element`** — The branded recursive root descriptor. See [PibblNode](/reference/types/elements-components/#pibblnode).

- **`config`** — Surface and lifetime options. See [PibblConfig](/reference/types/canvas-runtime/#pibblconfig).

### Returns

The stable [PibblController](/reference/types/canvas-runtime/#pibblcontroller), synchronously.

### Throws

Throws on compilation/mount failure, or AbortError for a pre-aborted signal.
Supersedes pending asynchronous requests for this Canvas.

### See also

[PibblController](/reference/types/canvas-runtime/#pibblcontroller)

[PibblConfig](/reference/types/canvas-runtime/#pibblconfig)

[View source — packages/core/src/sync.ts:20](/source/packages/core/src/sync-ts/#L20)

## Implementation guidance for agents

Read the [Authoring, signals, and lifecycle companion](/agents/topics/lifecycle/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Automatic JSX runtime](/minimal-examples/compiler/production/): The production compiler emits jsx and jsxs calls for component values and fragments. [Plain source](/minimal/compiler/production.ts)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.
