Skip to main content
Version: v1 (Current)

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:

FeatureWhat it shows
gxp-stringReplaces an element's text with a value pulled from the datastore
gxp-srcSwaps an <img>'s src to an asset URL from the datastore
gxp-settingsReads from manifest.settings instead of manifest.strings
gxp-stateReads 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-propsDeclarative click tracking with additional JSON properties
Injected gxpTrackProgrammatic 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, reactive context, busy/error state, action dispatch.
  • useExperienceApi({ callApi }) — adapter that turns a callApi-shaped function into typed named operations (publishPost, createPrintJob, processImage, …). Includes a bridge from gxpStore.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 #loading and #error="{ error, retry }" slots.
  • Action examples — built-in named actions and inline async functions. The comments explain false for disabling actions, but the shipped page list does not contain an explicit action: false example.
  • Branching paths — three parallel sub-flows (📷 photo, 🎨 drawing, ✍️ note) gated by when: (ctx) => ctx.choice === 'photo'. They converge on a shared final page.
  • withExperienceDefaults — pre-tagging your own page components with a default action and resultKey so 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 via goTo), 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​

  1. Run gxdev init my-plugin, change into my-plugin, then run gxdev dev --no-https=true for an explicit HTTP preview. See Getting Started for current flag parsing and prerequisites.
  2. Open the dev preview and explore DemoPage.vue — toggle values in Dev Tools (Ctrl+Shift+D) and watch the directives react.
  3. Click "Open Experience Demo →" to jump to DemoExperience.vue. Open the file alongside the preview and step through the kiosk while reading the code.
  4. Mutate the page list: reorder, remove terms, add a when predicate, swap a default action for an inline function. The state panel makes every change visible.
  5. Once comfortable, replace the demo imports and template branches in Plugin.vue with your real components, then delete the unused demo files and run the project build.

Replace the teaching defaults before publishing​

AreaDemo behaviorWhat to verify in your plugin
NavigationA local route ref selects a componentURL navigation, refresh behavior, and back navigation if your product needs them
API transportSynthetic responses and an artificial delayDeclared manifest operation keys, dependencies, permissions, and real success/error envelopes
MediaCamera/drawing branches produce browser mediaCamera permission denial, unavailable devices, upload limits, and supported target browsers
Note submissionReturns a local timestamp and captionA real persistence operation and its failure path if notes must be stored
LoadingWaits before returning a fabricated resultActual job completion, timeout, retry, and cancellation behavior
Final pagePlaceholder QR URL and action labelsReal output links and handlers for email/download actions
CompletionResets the flowClear session/context data appropriately for your shared-device workflow
StylingGlobal appui stylesheet plus component stylesBoth 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​