Template Demos
A new project scaffolded with the default gxdev init template includes two annotated demo pages under src/. Initializing an existing project can preserve its existing files, so inspect what was actually generated. They're not part of your final plugin — they're meant to be read, modified, or replaced as you learn how the platform, devtools, and appui fit together.
The root component Plugin.vue exposes a lightweight in-app route ref that switches between the two:
<DemoPage v-if="route === 'home'" @navigate="navigate" />
<DemoExperience v-else-if="route === 'experience'" @navigate="navigate" />
Replace this with vue-router when building real pages. Before deleting either demo file, remove or replace its static import and template branch in Plugin.vue; leaving those references makes the build fail.
DemoPage.vue
A flat single-screen demo that exercises the core devtools integrations:
| Feature | What it shows |
|---|---|
gxp-string | Replaces an element's text with a value pulled from the datastore |
gxp-src | Swaps an <img>'s src to an asset URL from the datastore |
gxp-settings | Reads from manifest.settings instead of manifest.strings |
gxp-state | Reads from the live triggerState (updated via sockets or CLI) |
gxpStore.getSetting(key) | Programmatic read of a setting in <script> |
gxpStore.broadcast(socket, event, data) | Send an event through the named socket; no room-isolation guarantee |
gxpStore.listen(socket, event, cb) | Subscribe to events from other windows / clients |
gxp-track and gxp-track-props | Declarative click tracking with additional JSON properties |
Injected gxpTrack | Programmatic tracking of custom milestones |
Open Ctrl+Shift+D in the dev preview to inspect configuration and edit supported settings/string fields. Asset and trigger-state rows are display-only; use the store console helpers or socket simulator as appropriate. See Dev Tools for control and persistence limits.
The socket demo uses the primary connection and demo-message event. Its sent list is updated locally after calling broadcast; it is not a server receipt. Use a second preview window to check reception, and follow Socket Events for relay behavior and connection troubleshooting. The component removes its event subscription when unmounted.
The analytics panel listens for development gxp:track browser events. Entries in that panel establish local tracking behavior, not durable production analytics storage. Verify the live platform tracking path separately before using those events for reporting.
DemoExperience.vue
A multi-stage kiosk-style flow built with @gxp-dev/app-ui's experience-flow system. It's the most heavily annotated file in the template — read top to bottom to learn the orchestrator end-to-end. What it covers:
useExperience(config)— the state-machine composable. Owns navigation, reactivecontext, busy/error state, action dispatch.useExperienceApi({ callApi })— adapter that turns acallApi-shaped function into typed named operations (publishPost,createPrintJob,processImage, …). Includes a bridge fromgxpStore.callApi(operationId, dependencyIdentifier, data)to the appui's(endpoint, payload)shape, with a deliberately selected mock transport for offline development.<ExperienceFlow :flow>— renderer with built-in loading/error overlays, customized via the#loadingand#error="{ error, retry }"slots.- Action examples — built-in named actions and inline async functions. The comments explain
falsefor disabling actions, but the shipped page list does not contain an explicitaction: falseexample. - Branching paths — three parallel sub-flows (📷 photo, 🎨 drawing, ✍️ note) gated by
when: (ctx) => ctx.choice === 'photo'. They converge on a sharedfinalpage. withExperienceDefaults— pre-tagging your own page components with a defaultactionandresultKeyso you don't repeat the wiring at the call site.- Live state inspector — a side panel that mirrors the orchestrator: current page, busy / error refs, the reactive
context, per-page jump buttons (validated viagoTo), and a "Force error" button for previewing the custom error slot. - Reset & loop —
onComplete: (ctx) => flow.reset()so the kiosk returns to the welcome screen when the user finishes.
The Force error control directly assigns a synthetic error to the flow. Dismiss clears that overlay without advancing the page; this demonstrates the error UI rather than a failed backend request being retried. Jumping to a branch page whose when predicate is false rejects the navigation. Reset clears branch results and restores the initial context.
Style isolation
@gxp-dev/app-ui/styles (Tailwind utilities + theme tokens) is imported inside DemoExperience.vue. However, Plugin.vue imports that component statically: switching a v-if route does not defer module evaluation or guarantee that global styles load only when the experience page opens. Check both demo pages for global style interactions. In a real plugin that uses appui throughout, place the stylesheet import at the root so its ownership is clear.
Real callApi wiring
The file ships with a mockCallApi for offline browsing of the demo. To wire it to the live platform, replace the mock with:
const callApi = (endpoint, payload) => gxpStore.callApi(endpoint, "experience_api", payload)
Here experience_api is an example dependency identifier: replace it with the declared identifier in your app-manifest.json. The endpoint argument must be an operation key bound by that dependency, not an arbitrary URL or an adapter default assumed to exist. Configure useExperienceApi's endpoints for the actual operations used by your flow; resolve different dependencies explicitly if needed. See GxP Store for the three-argument contract. Missing or denied live bindings must remain errors; the demo's mock transport is only for deliberately offline browsing. The bundled mock returns a synthetic post for social_stream.createPost and a generic { data: { ok: true } } for other operation names. Completing a demo flow therefore does not establish that printing, image processing, or another live platform operation succeeded.
Suggested learning path
- Run
gxdev init my-plugin, change intomy-plugin, then rungxdev dev --no-https=truefor an explicit HTTP preview. See Getting Started for current flag parsing and prerequisites. - Open the dev preview and explore
DemoPage.vue— toggle values in Dev Tools (Ctrl+Shift+D) and watch the directives react. - Click "Open Experience Demo →" to jump to
DemoExperience.vue. Open the file alongside the preview and step through the kiosk while reading the code. - Mutate the page list: reorder, remove
terms, add awhenpredicate, swap a default action for an inline function. The state panel makes every change visible. - Once comfortable, replace the demo imports and template branches in
Plugin.vuewith your real components, then delete the unused demo files and run the project build.
Replace the teaching defaults before publishing
| Area | Demo behavior | What to verify in your plugin |
|---|---|---|
| Navigation | A local route ref selects a component | URL navigation, refresh behavior, and back navigation if your product needs them |
| API transport | Synthetic responses and an artificial delay | Declared manifest operation keys, dependencies, permissions, and real success/error envelopes |
| Media | Camera/drawing branches produce browser media | Camera permission denial, unavailable devices, upload limits, and supported target browsers |
| Note submission | Returns a local timestamp and caption | A real persistence operation and its failure path if notes must be stored |
| Loading | Waits before returning a fabricated result | Actual job completion, timeout, retry, and cancellation behavior |
| Final page | Placeholder QR URL and action labels | Real output links and handlers for email/download actions |
| Completion | Resets the flow | Clear session/context data appropriately for your shared-device workflow |
| Styling | Global appui stylesheet plus component styles | Both demo and real pages under your selected portal theme |
Inspect the generated source instead of treating the template as a production-ready integration. In particular, replacing mockCallApi alone does not implement every final-page action or turn the simulated loading task into backend polling.
See also
@gxp-dev/app-uiexperience-flow overview — the orchestrator API in depth.- Pages reference — every prebuilt page's props, emits, slots, default action.
- API adapter —
useExperienceApioperations and override patterns. - GxP Store — the
callApi,broadcast, andlistenprimitives the demos call into.