Last Updated: November 2026 · Plugin API: 1.1
Plugin API 1.1 gives client bundles four helpers on window.__pokerEngine, so a plugin can look like the host, speak the player’s language and call its own routes without copying core code:
| Key | What it is |
|---|---|
ui | Themed components plus the app’s toasts and confirm dialog |
i18n | Plugin strings in the app’s i18next instance, scoped to plugin.<providerType>. |
http | Authenticated requests to /api/v1/plugins/<providerType> |
auth.currentUser(), auth.subscribe(cb) | A read-only view of the signed-in player |
Types come from @poker-engine/plugin-sdk/client (PokerEngineClient, PluginUiKit, PluginI18n, PluginHttpClient, PluginCurrentUser, …). Plugin pages also receive ui, t and http as props (PluginPageProps).
import type { PluginPageProps, PokerEngineClient } from '@poker-engine/plugin-sdk/client';
const PROVIDER_TYPE = 'daily-wheel';
export function setup(engine: PokerEngineClient) {
const { t } = engine.i18n.for(PROVIDER_TYPE);
const http = engine.http.for(PROVIDER_TYPE);
function SpinBanner() {
const { Card, Button } = engine.ui;
const spin = async () => {
try {
const result = await http.post<{ label: string }>('/spin');
engine.ui.toast.success(t('won', 'You won {{prize}}!', { prize: result.label }));
} catch (error) {
engine.ui.toast.error(engine.http.isHttpError(error) ? error.message : t('failed', 'Spin failed'));
}
};
return (
<Card title={t('title', 'Daily wheel')}>
<Button onClick={spin}>{t('spin', 'Spin')}</Button>
</Card>
);
}
engine.fills.register('lobby.top', SpinBanner, { providerType: PROVIDER_TYPE });
}
export function WheelPage({ ui, t, http }: PluginPageProps) {
// same helpers, already bound to this plugin
}
engine.ui
Every component uses the app’s palette utilities, which read the theme token bridge, so it follows the active theme on player pages (and the admin’s own colour scheme on admin pages) and mirrors in right-to-left languages. Plugin bundles cannot add Tailwind classes of their own (Tailwind only compiles classes found in the client source), so prefer these components and keep any custom styling to layout (display, gap, padding) with colours inherited from the host.
Admin pages: light and dark. Plugin admin pages render inside the admin shell, which has its own colour scheme: light by default, with a dark option each admin can switch to in the header (remembered per browser, shown as data-admin-scheme="light|dark" on <html>). Under [data-surface="admin"] every palette token takes the admin’s light value unless the scheme is dark, and player themes never reach the admin. engine.ui components follow the scheme with no work on your side. Colours a bundle hard-codes do not: an inline style={{ background: '#1f2937', color: '#fff' }} or a stylesheet with fixed hex values stays dark in the light admin (or light in the dark one). Use engine.ui, let text inherit the host’s colour, and where you need a colour of your own on an admin page, use a palette token such as var(--th-gray-800) (a card surface) or var(--th-gray-400) (muted text), which is set in both schemes. Palette names are roles, not literal colours: var(--th-white) is heading text and turns dark in the light admin; for text on a solid coloured fill use var(--th-on-accent), which stays white.
| Component | Props |
|---|---|
Button | Native button props plus variant: 'primary' | 'secondary' | 'ghost' | 'danger' (default primary), size: 'sm' | 'md' | 'lg', loading (spinner, disabled), icon. type defaults to button. |
Card | Div props plus title, actions (end of the header row), padding: 'none' | 'sm' | 'md' | 'lg', headingLevel: 2 | 3 | 4 (default 3; use 2 for a card directly under the page’s h1, such as a lobby banner or sidebar card) |
Modal | open, onClose, title, children, footer, size: 'sm' | 'md' | 'lg', dismissible (backdrop closes; default true). Portalled to <body>, focus moves in and back, Tab is trapped, Escape closes. |
Badge | Span props plus tone: 'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info' |
ProgressBar | value, max (default 100), label, showValue, tone. Clamped, role="progressbar". |
Tabs | tabs: { id, label, content?, disabled? }[], value/onChange (controlled) or defaultValue, ariaLabel. Arrow keys, Home and End move between tabs. |
Table | columns: { key, header, render?(row, i), align? }[], rows, rowKey?, empty?, caption?, rowAttributes?(row, i) (API 1.4: data-* attributes for each body row, such as a test id or the record’s id, e.g. (row) => ({ 'data-testid': 'campaign-row', 'data-id': row.id }); other names are ignored). Scrolls sideways inside its own box when the columns do not fit. |
EmptyState | title, description, icon, action |
Spinner | size, label (accessible name, default "Loading") |
Tooltip | content, children, side: 'top' | 'bottom'. Shown on hover and keyboard focus. |
PageHeader (API 1.4) | title, description, actions. The page’s one <h1> with a one-line description, as on the core admin pages. Give every admin page one, and no padding of its own: the admin shell already pads the page. |
Input (API 1.4) | Native input props plus label (required, tied to the control), labelHidden, hint, error (marks the field invalid), suffix (a unit inside the box). className and style apply to the field’s wrapper. |
Select (API 1.4) | Native select props plus options: { value, label, disabled? }[] (or <option> children) and the same label, labelHidden, hint, error, className, style. |
Textarea (API 1.4) | Native textarea props plus monospace and the same field props. |
On admin pages Button matches the admin’s own buttons: 40px tall on touch screens (sm is 32px from 1024px wide). On player pages the sizes are unchanged. Input, Select and Textarea are 40px tall with a visible border in both admin schemes.
| Function | Behaviour |
|---|---|
toast.success(message, { duration? }), toast.error(...), toast.info(...) | The app’s toast stack. Messages are cut at 500 characters; empty messages are ignored. |
confirm({ message, title?, confirmText?, cancelText?, variant? }) | The app’s confirm dialog. Resolves true when confirmed, false when cancelled or replaced by another dialog. |
engine.i18n
Plugin strings live in the plugin namespace of the app’s i18next instance, under the plugin’s providerType: the full key of levelUp in the progression plugin is plugin.progression.levelUp. A plugin cannot read or overwrite core strings: namespace separators in keys are ignored and interpolation values are passed as values only, never as i18next options.
| Member | Description |
|---|---|
for(providerType) | { t, registerLocale(lang, resources), language, onLanguageChange } bound to one plugin. Use this. |
t(key, fallback?, vars?) | Translates plugin.<key>, so the key starts with the providerType (t('progression.levelUp')). Returns fallback (interpolated), else the key, when no translation exists in the current language or en. |
registerLocale(providerType, lang, resources) | Deep-merges nested string maps for a language. Non-string values are dropped. |
language() | Current UI language code, e.g. en or pt-BR. |
onLanguageChange(cb) | Called with the new code after each switch; returns an unsubscribe function. Re-render on it if you cache translated text. |
vars fill {{name}} placeholders; a numeric count also selects i18next plural forms (key_one, key_other). Keep the plain key as the plural ("other") form and add key_one beside it, so t('streak', 'Login streak: {{count}} days', { count }) reads "1 day" and "2 days". When the shown number needs formatting (1,500), pass it under another name and the raw number as count: t('chips', '{{amount}} chips', { amount: '1,500', count: 1500 }).
Translations
Ship your strings as JSON files and declare them in the manifest:
"pokerEnginePlugin": {
"apiVersion": "1.1",
"locales": { "en": "dist/locales/en.json", "de": "dist/locales/de.json" }
}
- Files must sit directly in
dist/locales/(the engine serves/plugins/<providerType>/dist/locales/<file>.jsonand nothing else outsidedist/client/). Other paths are skipped with a warning. - Each file is the plugin’s own tree, without the
plugin.<providerType>prefix:{ "levelUp": "Level {{level}}!", "missions": { "title": "Missions" } }. - The app fetches the current language, its base language (
ptforpt-BR) andenbefore injecting the bundle (at startup and on live activation or upgrade), waiting at most 3 seconds. Switching language loads that language’s file. GET /api/v1/config/plugin-scriptsreturns the URLs in each entry’slocalesfield.- The demo plugin copies
src/locales/*.jsontodist/locales/inbuild.client.mjs; copy that step into your own build.
Always pass an English fallback to t(): strings render even if a locale file fails to load.
engine.http
engine.http.for(providerType) returns a client for the routes the plugin registered with registry.registerRoute:
| Method | Request |
|---|---|
get<T>(path, { params?, headers? }) | GET /api/v1/plugins/<providerType><path>?<params> |
post<T>(path, body?, options?) | POST with a JSON body |
put<T>, patch<T> | Same as post |
delete<T>(path, options?) | DELETE |
baseUrl | /api/v1/plugins/<providerType> (the same as PluginPageProps.apiBase) |
It goes through the app’s API client, so:
- cookies are sent and an expired access token is refreshed once, as for core requests;
POST,PUT,PATCHandDELETEcarry theX-CSRF-Tokenheader for signed-in players (and retry once on a stale token);- the
{ success, data }envelope is unwrapped: the promise resolves withdata; - failures reject with
ApiClientError(message,codefrom the envelope’serror.code,status,details). Check withengine.http.isHttpError(error); GETis retried on network errors and 5xx; state-changing methods are never retried, so an action cannot run twice by accident.
Paths are relative to the plugin: anything that would leave /api/v1/plugins/<providerType> (.. segments, encoded slashes, absolute URLs) throws before a request is sent. For core endpoints use engine.api.buildUrl() with fetch.
engine.auth
| Member | Description |
|---|---|
currentUser() | null, or { id, username, role, avatar?, balance, virtualBalance, tournamentTickets?, isAgent, preferredLanguageCode? }. A fresh copy each call; email and names are not exposed. |
subscribe(cb) | Called with the player (or null) on sign-in, sign-out and any change to those fields (a balance update, for example). Not called on subscribe; returns an unsubscribe function. |
login(user, expiresIn) | Unchanged: completes a plugin-initiated (SSO) login. |
registerCredentialStarter(providerType, providerId, start) (API 1.4, optional) | Show a credential login provider (definition button: true) as a "Continue with …" button in the host’s provider buttons, on the login and register screens of every theme. start({ intent: 'login' | 'signup', returnTo, ref }) runs on click; post the credential and pass the answer to continueExternalSignIn. Returns an unregister function; dropped when the plugin is deactivated or updated. createTestEngine() records starters in engine.auth.credentialStarters. Used by guest-login. |
continueExternalSignIn(data) (API 1.4, optional) | Hand the data of POST /api/v1/auth/external/:provider/credential to the app: it goes where the core /auth/external/finish page would (signed in to returnTo; the login page’s 2FA step for requires_2fa, also when that page is already showing; the complete-profile step; the "sign in to link" notice; Settings → Sign-in methods for linked, and its set-password form for reauth_ok). Returns 'navigated', or 'pending_approval' / 'email_verification_required' for the plugin to explain; throws a TypeError for anything that is not such a result. Optional so a plugin can check for it on an older engine; createTestEngine() has a spy that returns 'navigated'. Used by telegram-auth 2.0. |
engine.notifications (API 1.3)
| Member | Description |
|---|---|
markRead(id) | Marks one of the signed-in player’s core notifications read (an id from the notifications.item.actions props) and tells the header bell and the notifications page to reload, so the unread count drops at once. Rejects when the request fails. |
The member is optional on PokerEngineClient: check engine.notifications before using it so the plugin still runs on an older engine. The notifications plugin uses it to mark a campaign notification read once its reward is claimed.
Page placement and redirects (API 1.3)
Plugin pages extend the product’s pages instead of standing beside them.
Sections. nav.section decides where a page registered with engine.pages.register is listed:
| Area | nav.section | Listed |
|---|---|---|
admin | An admin section id: users (or user-management), game (or game-management), bots (or bots-management), finance, compliance, marketing, affiliates, agents, content, appearance, email, developer (or developer-api), settings | In the group it maps to (Players, Games, Games › Bots, Money, Risk & Compliance, Growth, Growth › Agents, Site & Content, Extensions › Developer API, Settings: see the full table), sorted by nav.order |
admin | plugins, unknown, or none | Extensions › Plugin Pages |
user | main (or none) | The main navigation (header and drawer) |
user | account | With the account links (the user menu in the bundled themes) |
nav: false keeps a page out of every list, even when the manifest gives it a title: it is reachable by link or by a tab only. The nav:items:user filter receives each user item with its section and order (Client Hooks).
Redirects. engine.pages.redirect({ providerType, from, to, area? }) forwards an old page path to a new URL in the app, with :param substitution and the query string passed through:
import type { PageRedirectRegistration, PokerEngineClient } from '@poker-engine/plugin-sdk/client';
export function setup(engine: PokerEngineClient) {
const moved: PageRedirectRegistration[] = [
{ providerType: 'notifications', from: '/claim/:token', to: '/notifications?claim=:token' },
{ providerType: 'notifications', from: '/preferences', to: '/settings#notifications' },
];
for (const entry of moved) engine.pages.redirect(entry);
}
/ext/notifications/claim/abc?ref=mail is replaced by /notifications?claim=abc&ref=mail. to must start with a single / (a target outside the app throws). Manifest redirects declare the same entries without code; see Page redirects.
Testing
createTestEngine() from @poker-engine/plugin-sdk/testing/client includes doubles for all of the above:
import { createHttpError, createTestEngine } from '@poker-engine/plugin-sdk/testing/client';
const engine = createTestEngine({ user: { id: 'u1', username: 'ann', role: 'user', balance: 0, virtualBalance: 0, isAgent: false } });
engine.i18n.registerLocale('daily-wheel', 'en', en); // in-memory i18n (plural forms like the engine); engine.i18n.setLanguage('de')
engine.http.for('daily-wheel').post.mockResolvedValue({ label: '100 chips' });
engine.http.for('daily-wheel').get.mockRejectedValue(createHttpError('Come back later', 'COOLDOWN', 429));
setup(engine);
expect(engine.ui.toast.success).toHaveBeenCalled(); // toast.* and confirm are spies
engine.auth.setUser(null); // notifies auth.subscribe callbacks
The UI doubles render plain HTML with a data-pe-ui="<component>" attribute (and data-tone on badges), so renderToStaticMarkup or Testing Library can assert on them.
Admin side
- Capability consent. Activating a plugin that declares
capabilitiesopens a dialog listing each one in plain language (high-impact ones, such as real-money credits and bonuses, are flagged). Confirming sendsPOST /api/v1/admin/plugins/:id/activatewith{ grantCapabilities }; cancelling leaves the plugin inactive. If the server answers 409CAPABILITIES_NOT_GRANTED(the plugin declares more than was granted, for example after an upgrade), the dialog reopens with the missing capabilities marked "Not granted". Plugins without capabilities activate directly, as before. See Capabilities. - Plugin details. Each row of the plugins list (Extensions › Plugins) shows its declared capabilities (granted ones highlighted). View details opens a side panel with the plugin’s status, health, version and technical name, its granted and not-granted capabilities with descriptions, its scheduled jobs (schedule, last run, next run, status) when the server has the jobs endpoint, and, for a plugin that can credit balances, its Wallet daily caps.
- Settings.
jsonandlistconfig fields get dedicated editors; see configFields types.
See also: Plugin Development Guide, Realtime for engine.socket, Slot Fills, SDK.
Source: client/src/core/plugin-ui/, client/src/core/plugin-i18n.ts, client/src/core/plugin-http.ts, client/src/core/plugin-auth.ts, client/src/core/plugin-toolkit.types.ts, client/src/pages/admin/PluginCapabilityConsent.tsx, client/src/pages/admin/PluginConfigEditors.tsx, src/core/plugins/plugin-config-fields.ts.