GxP Store
The GxP store connects a plugin to its page's configured content, resource bindings, API operations, and real-time channels. Use the host-provided store rather than creating a second Pinia store or embedding the toolkit's preview implementation into a production plugin.
This guide compares toolkit 2.1.40 with platform store revision
5cf2925bcbb58fc397205ac553d7827ccab4c996, with the runtime baseline reviewed on 2026-10-14 and the toolkit guidance delta reviewed on 2026-10-15.
Their public interfaces overlap, but their transports, scope, and some
helpers differ. A working preview is not proof of installed permissions,
authentication, offline behavior, or delivery.
The socket name-compatibility delta is additionally reviewed at platform develop 25e1564 on 2026-10-19; it does not refresh every other contract below or establish deployed availability.
Importing the Store
Use the scaffold's public store import:
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
const store = useGxpStore()
The managed Vite configuration maps this import to the host's store bridge.
@gx-runtime/stores/... addresses toolkit runtime code; it is useful for
runtime development, but is not the production plugin interface.
The platform keeps stores by page ID and resolves the nearest provided
store in component setup. Resolve it during setup and retain that instance
in callbacks, especially when a portal contains widgets with their own
stores. Module exports include getGxpStoreById, GXP_STORE_ID_KEY,
disposeGxpStore, and setDefaultPageStoreId. The local toolkit accepts an
optional ID but hosts a single store; it does not demonstrate multi-page
isolation. Store creation/disposal and default-page selection belong to the
host, not an individual child plugin.
Store Sections
| Section | Contents / ownership |
|---|---|
pluginVars | Installation settings plus page/project/form context |
stringsList | Selected text content |
assetList, staticAssetList | Configured dynamic assets and packaged static assets |
dependencyList | Installed resource bindings keyed by identifier |
permissionFlags, navigationFlagsKeyed | Host-provided page flags; not browser/OS permissions |
auth, userSession | Current principal/session context; guard auth.user for guests |
portal, portalAssets | Portal context and portal assets |
triggerState | Reactive runtime state |
widgetStates | State of the portal widgets the app binds, keyed by dependency identifier (verified at platform 208d36e1b5) |
theme | Computed theme settings, using the color keys listed below |
sockets, connectionStatus | Available channel facades and connection status |
apiOperations | Registry loaded from the environment's OpenAPI specification |
form | Attached form store when the host/configuration supplies a form |
isOnline | Browser connectivity indication; not API availability or replay completion |
There is no generic router property in the reviewed store exports. Use the
navigation interface supplied to the actual app/component. Likewise, do not
assume a state key exists merely because an older example names it.
Getter Methods
getString(key, defaultValue)
Returns the string value or a nullish fallback. An explicit empty string is preserved:
const title = store.getString("welcome_title", "Welcome")
getSetting(key, defaultValue)
Reads pluginVars with a nullish fallback. false, 0, and an empty string
are real values, so use explicit type/validity checks for numeric settings.
getAsset(key, defaultValue)
Checks dynamic assets, then static assets. Blank/falsy values fall through. If the requested key is missing, a path-shaped fallback's final filename is also looked up before the fallback is returned. Pass a string fallback.
getState(key, defaultValue)
Reads triggerState with a nullish fallback. Define appropriate initial
state and handle a reload replacing those defaults.
getWidgetState(identifier, key, defaultValue)
Reads one key of a bound portal widget's state, by the dependency identifier
that binds the widget, with a nullish fallback. At platform 208d36e1b5
(reviewed 2026-11-05), the page's render payload supplies widgetStates as
{ [identifier]: { id, state } }, limited to the keys the app may read
through view_trigger_state. It includes widgets bound by ID or by the
dashboard picker's typed value (App\Models\ProjectPortalWidget:12). Toolkit 2.1.47 also supplies this getter for local fixtures.
const nowPlaying = store.getWidgetState("jukebox_widget", "now_playing", "")
See portal widgets as shared state.
hasPermission(permission)
Checks permissionFlags.includes(permission). It does not request browser
camera/notification access, validate an attendee session, or authorize an
API call. Local flags come from the manifest and can differ from the
installed page. Server authorization remains decisive.
Principal and group access
Use store.auth?.user for the current principal. It may be null, and a
logged-in principal can be a reader rather than an attendee. Check the
relevant type and API requirements; truthy user data alone is insufficient.
getGroups, getGroupNames, getGroupSlugs, inGroup, and inAnyGroup
read the groups supplied in that principal's context. The platform curates
portal-visible groups; a client-side group check is not a server grant.
The local dummy user is fixture data, not an authenticated platform attendee.
Update Methods
Shared exports include updatePluginVar, updateString, and updateAsset.
They mutate local reactive values. They do not save installation settings,
update an attendee, or persist a platform record; host reloads can replace
those values. Prefer consuming admin-managed content and mutate
triggerState for the plugin's own temporary state.
updateString(key, value)
Use for a deliberate in-memory text change. The platform remains the owner of persisted strings and selected locale content.
updateSetting(key, value)
This alias exists only in the local toolkit. The shared method is
updatePluginVar; neither is a server-side configuration save.
updateAsset(key, url)
Changes the reactive asset map without uploading a file. Use the platform's asset configuration/upload workflow for durable changes.
updateState(key, value)
This helper exists only in the local toolkit. Shared plugin code can update
store.triggerState[key] directly. A state edit does not automatically
broadcast or save it: it changes this browser only and is gone on reload. To
change state for every client, use the
Trigger State API (verified at platform 208d36e1b5).
addDevAsset(key, filename)
A development helper that builds a localhost image URL using the current page protocol/port (or its fallback port). It does not package or upload that image. Prefer configured asset bindings for released code.
Other local conveniences
user, getUser, getUserName, getUserEmail, isAuthenticated,
manifestLoaded, manifestError, applyManifest, loadManifest,
updateSetting, and updateState are not exported by the reviewed platform
store. apiPatch is exported by the platform store at the reviewed 208d36e1b5 checkpoint. Use auth.user, shared getters, and declared
operations in production plugin code. Confirm the deployed interface when
maintaining an app built against another version.
Dependency API Client
The store builds its operation registry from OpenAPI, not by parsing method/path strings in your manifest at call time. Discover the actual operation and declare the app dependency; the platform separately evaluates the installed page's bindings and permission rules.
callApi(operationId, identifier, additionalData)
| Argument | Meaning |
|---|---|
operationId | Discovered OpenAPI operation ID; a short ID can fall back to portal.v1.project.<shortOperationId> |
identifier | Installed dependency key used to resolve a parent resource; null is appropriate only for an operation needing project context alone |
additionalData | Schema-valid path/query/body values; may contain top-level Blob/File values or be FormData |
The request flow is:
- Load/reload an empty registry and find the operation's method and path.
- Read
pluginVars.projectIdasteamSlug/projectSlugand inject those values. - Resolve the dependency value into a matching path parameter, using declared
parent relation metadata where appropriate; inject
formIdwhen applicable. - Merge additional data, including supported
pluginVars.<key>references; explicit path values can override the initial binding/context values. - Encode path substitutions and remove them from ordinary query/body data.
- Add
/apito the OpenAPI path; GET/DELETE use query parameters, while POST/PUT/PATCH use a request body. - Return the response's parsed data. Do not assume every endpoint returns an array.
The current implementation excludes top-level null/undefined values from
ordinary object data. Values starting with pluginVars are interpreted as
setting references. Test nullable updates and literal text payloads rather
than assuming all values pass through unchanged.
A mixed array binding contributes numeric IDs as a CSV path value. Tags,
untagged tokens, and nonnumeric slug arrays do not become concrete numeric
path values. resolveDependency(identifier) returns { ids, tags, untagged };
findDependency(identifier) returns the raw configured value. These helpers
do not discover or authorize a resource for you.
findDependency returns a configured resource binding; it does not select a project or turn one model into another. Runtime project context comes from pluginVars.projectId. Match the binding to the declared model and parent scope. Although the request builder can merge explicit path overrides, do not use team/project overrides to cross tenants or relabel an Attendee binding as a Project.
Do not gate callApi solely on hasPermission: it reads global UI flags, and a granted dependency operation can work when that flag is absent. Let the server decide the requested operation and show a safe denied state for 403/404. Use fixed user-facing error text rather than raw error.message or upstream response bodies, and clear stale results when the binding or permission context changes.
For count responses, require Number.isSafeInteger(total) && total >= 0 before displaying success; reject missing, fractional, negative, non-finite or unsafe values. Rendering only a count does not minimize the network payload. Missing/empty visible-field selections inherit broader available fields. Review nonempty per-model page-principal ceilings, same-model unions, endpoint serializers and actual response keys as explained in permissions and dependencies. Development mocks do not establish production filtering.
An illustrative error-handling pattern is:
// Discover these values and configure the declared binding first.
try {
const result = await store.callApi(operationId, dependencyIdentifier, requestData)
// Render according to this operation's documented response schema.
} catch (error) {
if (error.status === 403) {
// Show the app's unavailable-access state; retain the denied binding.
} else {
// Show an appropriate failure state and allow a deliberate retry.
}
}
This is a pattern, not a complete endpoint tutorial. Ordinary HTTP failures
carry a numeric status for 400–599 responses; transport, registry, missing
parameter, and some offline failures may not. Error objects do not expose
the underlying request headers/configuration. Avoid blindly retrying a write
when delivery is uncertain.
The registry has no operation after a failed spec load, so inspect the
specification request separately from the resource request. A missing
required path parameter throws before sending. An invalid/missing
projectId currently returns []; do not interpret that empty result as a
successful API read.
Uploads and authentication context
For POST/PUT/PATCH, top-level Blob/File values or FormData use multipart transport with authentication headers retained. Let the browser create its boundary. When supplying FormData, also verify required path values: entries are not copied into the normal plain-object path-parameter loop.
The host supplies the bearer and page-context token; the store sends
Authorization and X-Portal-Page-Token when populated. Their roles can
coincide or differ. A page token is not automatically an attendee login.
Do not paste privileged project/provider credentials into source or public
manifest defaults. Test the actual endpoint's required identity and scope.
The local preview uses a mock token or configured Vite proxy/direct API host. Mock mode can still load its operation catalog from a remote spec origin. The MCP catalog selector is separate again; see AI/MCP configuration.
Low-Level API Client
Legacy shared helpers are apiGet, apiPost, apiPut, and apiDelete.
They accept full /api/... paths and return parsed data, but have different
error wrapping from callApi. New generated platform access should use
declared operation bindings. Do not replace a denied/missing binding with
an endpoint helper. callApi can handle a discovered PATCH operation through
the shared interface.
apiPatch(endpoint, data) is present in the platform store at 208d36e1b5
(reviewed 2026-11-05), and the toolkit provides it for local preview. Older
runtimes may lack it; check the installed version. It sends the same page credentials as the other helpers:
// teamSlug/projectSlug come from store.pluginVars.projectId.
await store.apiPatch(`/api/v1/projects/${teamSlug}/${projectSlug}/trigger-state/self`, {
state: { slide: 2 },
})
These helpers throw an Error whose message names the method, path and the
transport error. Unlike callApi, the error has no status and does not
carry the response body, so a 403, a 404 and a 422 look alike. Use callApi
when the deployed catalog lists the operation and the app must tell them
apart.
Socket.IO Integration
Local development uses Socket.IO; the platform uses Echo channels and whispers. The local relay shares one connection across facades and rebroadcasts events broadly. It does not model private-channel isolation.
For peer messages, store.sockets.primary.listenForWhisper(event, callback)
and broadcast are the explicit socket-facade methods. store.listen(socketName, event, callback) is the shared convenience call; on primary it preserves
the whisper-listener alias. Always retain and call the returned cleanup.
// Illustrative setup pattern; store and handleCursor belong to your component.
const stop = store.sockets.primary.listenForWhisper("cursor_moved", handleCursor)
onUnmounted(stop) // import onUnmounted from Vue and register during setup
For server state, store.sockets.primary.listenForStateChange(callback)
merges each state event's changes into triggerState and then calls you.
The store does not keep triggerState live on its own; it merges only while
such a listener is registered. A form-backed page listens on
portal.forms.{formId}, other pages on portal.pages.{pageId}.
At platform 208d36e1b5, store.sockets.widgets.listenForStateChange(identifier, callback)
does the same for a portal widget the app binds, merging into
widgetStates (read with getWidgetState). It returns a no-op cleanup when
the identifier is not in widgetStates. A widget event carries every changed
key, so the widget's channel accepts the app only when it may read every key
(triggerStateKeys: ["*"]). An app limited to some keys reads them with the
Trigger State API instead.
Both helpers return a cleanup; a removed key becomes null rather than
disappearing. Toolkit 2.1.47 supplies a local widget relay facade; it does not enforce platform channel access. See
realtime events.
const stopOwn = store.sockets.primary.listenForStateChange((event) => {
console.log(Object.keys(event.changes))
})
const stopWidget = store.sockets.widgets.listenForStateChange("jukebox_widget", (event) => {
console.log(Object.keys(event.changes))
})
onUnmounted(() => {
stopOwn()
stopWidget()
})
For declared resource events, use the configured dependency facade such as
store.sockets[identifier][eventAlias].listen(callback) and retain its
cleanup. An absent facade, no-op preview listener, or local received event
is not proof of an authorized platform channel.
At platform develop 25e1564 (reviewed 2026-10-19), declared dependency
listeners register both short event names and their App\Events\ class-name
forms. Their returned cleanup removes the callback for both forms on available
resource/session channels. This host compatibility does not change local relay
isolation or validate unknown custom aliases. Check the deployed version and
actual producer; see event declarations.
emitSocket, listenSocket, and useSocketListener are legacy aliases.
The local extra listen(eventName, permissionIdentifier, callback) form is
not supported by the reviewed platform implementation. broadcast may
return true even when a socket is missing; verify a real receiver and the
expected server outcome rather than treating it as a receipt.
connectQuizChannel, leaveQuizChannel, and resyncQuizState belong to the
platform's native quiz integration and have transport-specific behavior.
Those helpers do not make guest quiz attempts authorized. The documentation
hub's embedded quizzes remain on hold.
Live quiz controller channels
At platform 208d36e1b5 (reviewed 2026-11-05), connectLiveQuizChannel(formId)
joins a quiz's controller channels for an app bound to it, with the page key.
formId is the quiz's numeric ID, which the live quiz management state
endpoint returns as form_id. It returns { onState, onAnalytics, leave }:
onState(callback) listens for trigger_state.changed on
portal.forms.{formId}.live, and onAnalytics(callback) for
analytics.updated on portal.forms.{formId}.live.analytics. Each returns a
cleanup that removes that callback. A channel is joined on its first
listener, so an app without view_live_quiz_analytics need never ask for the
analytics channel. leave() or leaveLiveQuizChannel(formId) leaves both,
for every listener on the page, since the store keeps one helper per quiz.
A refused channel authorization is not reported to the callbacks. Toolkit 2.1.47 provides a local relay adapter; see the preview section below. See
Building a Live Quiz Control Panel.
Widget and quiz preview helpers
The reviewed toolkit 2.1.47 adds local fixtures described in App Manifest. Match these helpers against your installed portal runtime before sharing code between environments; local simulation is not production channel authorization.
| Helper | Local behavior and lifecycle |
|---|---|
getWidgetState(identifier, key, fallback = null) | Reads widgetStates[identifier].state[key] with a nullish fallback |
sockets.widgets.listenForStateChange(identifier, callback) | Requires a fixture widget ID; filters widget-state-change by widget ID, merges changes, then calls the callback; returns a cleanup closure, or a no-op closure if unbound |
connectQuizChannel(formId) / leaveQuizChannel(formId) | Cached Echo-shaped adapter over the primary relay, with owned-listener cleanup; channel labels do not create relay isolation |
connectLiveQuizChannel(formId) | Cached controller adapter; returns null if the primary relay has not initialized; onState and onAnalytics return listener cleanup closures |
leaveLiveQuizChannel(formId) | Removes that adapter's listeners and cached entry; coordinate ownership when several consumers share it |
resyncQuizState(formId) | Calls portal.v1.project.quiz.state through dependency identifier form; a real operation/binding must exist in the selected catalog |
Start the mock relay and fetch manage state first; let the runtime initialize its primary socket before connecting. For a controller preview, use the numeric form_id returned by that response (7 in the fixture), not an assumed form slug:
const live = store.connectLiveQuizChannel(formId)
const stopState = live?.onState((event) => applyPreviewState(event.trigger_state))
const stopAnalytics = live?.onAnalytics((event) => showPreviewTally(event.answer_distribution))
// When this consumer unmounts or changes forms:
stopState?.()
stopAnalytics?.()
The snippet assumes your application supplies store, formId and the two rendering callbacks. Each consumer calls its own cleanup closures. The component/service owning the shared adapter should call store.leaveLiveQuizChannel(formId) when no consumers remain, so the cached entry is removed; calling it while another consumer is active removes that consumer’s listeners too. In the local adapter, trigger_state.changed and analytics.updated are filtered by form_id over the same primary socket. This does not reproduce private channel admission or protect tally data. Under API_ENV=mock, the liveQuiz fixture supplies questions and responses; confirm HTTP state and emitted events separately. Outside mock mode, verify the actual proxy/host before issuing a request. Do not use mock votes, labels or a connected socket as evidence of durable answers, scoring or reporting.
Reactive Usage in Templates
Use this complete component with the starting manifest from App Manifest. It demonstrates shared getters, derived theme values, and direct temporary state mutation:
<script setup>
import { computed } from "vue"
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
const store = useGxpStore()
const heading = computed(() => store.getString("welcome_title", "Welcome"))
const count = computed(() => store.getState("demo_count", 0))
const buttonStyle = computed(() => ({
backgroundColor: store.theme.primary_color,
color: store.getSetting("button_text_color", "#ffffff"),
}))
function increment() {
store.triggerState.demo_count = Number(store.getState("demo_count", 0)) + 1
}
</script>
<template>
<section>
<h1>{{ heading }}</h1>
<p>{{ store.getSetting("company_name", "Demo Event") }}</p>
<p aria-live="polite">{{ store.getString("count_label", "Count") }}: {{ count }}</p>
<button :style="buttonStyle" @click="increment">
{{ store.getString("increment_label", "Increase") }}
</button>
</section>
</template>
Read reactive properties/getters inside computed values or template expressions. Copying a scalar to a plain variable once does not keep it reactive across host updates. Register only your own subscriptions with component cleanup; do not dispose the host's shared store from a child plugin.
The manifest guide includes the scaffold, preview, build, and installation workflow for this component.
Watching Store Changes
Vue watch can observe a specific getter or property. Keep the scope narrow
and return/stop subscriptions you create outside component setup. Treat
manifest reload and navigation as possible context resets; do not persist
attendee-specific data in an unrelated page's global store.
Computed Properties
Derive display state with computed values rather than duplicating settings
or counts. Guard missing content, guest context, and nullable form before
accessing nested members. Define the app's loading/error states separately
from browser connectivity.
Theme Integration
The reviewed theme uses background_color, text_color, primary_color,
start_background_color, start_text_color, final_background_color, and
final_text_color. They are derived from settings, not generic primary,
background, or onPrimary keys. Use CSS properties appropriate to the
value; a background value can be a gradient rather than a solid color.
Forms, push, and offline state
store.form attaches when the host supplies a form ID or the local manifest
has a form fixture. attachFormStore is also exported, but it does not
provision a live form. Local schema hot reload rebuilds its form state and
can reset unsaved data. Verify the actual installed form's schema,
conditions, validation, submission identity, and server response.
Push helpers are loadPushSubscription, ensurePushSubscription,
subscribeToPush, and unsubscribeFromPush, with pushSubscription state.
They require supported browser/service-worker behavior and configured VAPID
keys/feature settings. Platform /push/* routes use the portal's session
context; the local API host is not a production push-service substitute.
A flag or returned subscription is not proof of delivered notifications.
The platform additionally exports pwaConfig, refreshPwaConfig,
syncStatus, and uploadQueue; these are absent from the reviewed toolkit
store. Offline interception depends on a controlling configured service
worker and selected operation strategies, not just isOnline. A queued
write/upload is distinct from server completion. Test offline/reconnect and
replay outcomes in the intended portal before relying on them.
Best Practices
Confirm the installed store/export surface, catalog, binding values, principal, and selected release before diagnosing an app. Validate locally with behavior tests and then test permitted/denied installed access. Use preview-only helpers only in preview code, handle empty/failure states, clean up your listeners, and verify durable writes and received events independently of local state changes.