# Vue, Solid & Svelte Order Boards

> The same order board built three times with @zwire/vue, @zwire/solid, and @zwire/svelte on one shared scoped model.

:::tip[Live previews]
Open the compiled boards in your browser: **[Vue](https://preview.zwire.studiocyf.app/adapter-orders/vue/)** · **[Solid](https://preview.zwire.studiocyf.app/adapter-orders/solid/)** · **[Svelte](https://preview.zwire.studiocyf.app/adapter-orders/svelte/)**
:::

The same small app written three times, once per adapter, on one shared model. It shows the four flows the adapter subpaths cover:

| Flow | Where to look | API |
| :--- | :--- | :--- |
| Per-scope state | [`shared/model.ts`](https://github.com/kjmin-dev/zwire/blob/main/examples/adapter-orders/shared/model.ts) | `scoped()`, `useScoped()` |
| Scope lifetime and hydration | each `main.ts` (Svelte: [`svelte/Root.svelte`](https://github.com/kjmin-dev/zwire/blob/main/examples/adapter-orders/svelte/Root.svelte)) | `ScopeProvider` without a `scope`, `HydrationBoundary`, `useHydrate` |
| Optimistic mutation | `App.vue`, `App.svelte`, `solid/main.ts` | `useOptimisticAction` |
| Lists | same files | `useCollectionTopK`, `useCollectionSize` |
| Async data | same files | `useResource` on a `lazy` resource |

What the page does:

1. The balance reads 1,000 on the first render: the provider creates a scope and the snapshot `{ balance: 1000 }` is hydrated into it before any component reads.
2. The profile shows `loading` until the lazy resource answers. The request starts when the first component reads it.
3. **Reserve 150** lowers the balance at once and shows `pending`. When the server answers, the layer is replaced by the server's balance in one step.
4. **Reserve 100000** is refused by the server. The optimistic edit is reverted and the error is shown.
5. Pressing both quickly opens two layers. They rebase in creation order and settle independently.
6. **Add order** inserts a row; the Top-3 list and the total update incrementally.

React has its own example, the [WASM order book](/examples/wasm-orderbook/).

## Run

From the repository root, with the pinned toolchains installed:

```sh
pnpm install --frozen-lockfile --ignore-scripts
mise run build:ts
mise run test:adapter-examples
python3 -m http.server 8080 --bind 127.0.0.1 --directory examples/adapter-orders/dist
```

Open `http://127.0.0.1:8080/vue/`, `/solid/` or `/svelte/`. The second task bundles the three views into `dist/` and runs [`smoke.mjs`](https://github.com/kjmin-dev/zwire/blob/main/examples/adapter-orders/smoke.mjs), which mounts each view in happy-dom and drives the six steps above through the DOM.

## How it is built

[`build.mjs`](https://github.com/kjmin-dev/zwire/blob/main/examples/adapter-orders/build.mjs) uses the bundler and compilers the test workspace already installs (Rolldown, `vue/compiler-sfc`, `svelte/compiler`), so the example adds no toolchain of its own. That is also why the Solid view builds its DOM with a small `el()` helper instead of JSX: no JSX compiler for Solid 2 is installed here. In an application, write it with your usual Solid setup; the zwire calls are the same.
