Documentation Index
Fetch the complete documentation index at: https://v5.rpgjs.dev/llms.txt
Use this file to discover all available pages before exploring further.
Vue.js 3 Integration with RPGJS GUI System
@rpgjs/vue lets RPGJS v5 projects use Vue 3 components for GUI overlays while keeping the regular server API:
.ce GUI components still render inside the canvas. Vue GUI components render in a DOM overlay above the canvas.
Setup
Install Vue support:.vue files:
provideVueGui() creates #vue-gui-overlay inside #rpg when the element does not exist and createIfNotFound is enabled.
Replace Prebuilt GUI
You can replace a prebuilt CanvasEngine GUI with a Vue component by registering a Vue GUI with the same ID. Server APIs keep using the same GUI ID, but the rendered component comes from Vue:player.showText() and player.gui(PrebuiltGui.Dialog).open(data) open the Vue dialog instead of the built-in CanvasEngine dialog. The same pattern works for other prebuilt IDs such as PrebuiltGui.MainMenu, PrebuiltGui.Shop, PrebuiltGui.Save, PrebuiltGui.TitleScreen, and PrebuiltGui.Gameover.
Each prebuilt GUI has a defined data and interaction contract. See Prebuilt GUI Contracts for the full list of fields, actions, and expected close values.
Use the regular Vue injections to close the GUI or send actions back to the server. For dialog boxes, closing with the selected choice index resolves player.showChoices():
Vue Components
Data passed throughplayer.gui(id).open(data) becomes Vue props:
v-propagate when mouse, pointer, and wheel events should also be forwarded to the game canvas.
Attached Vue GUI
Vue GUI components can follow sprites or events from the DOM overlay. Configure them withattachToSprite: true:
object and spriteData props:
rpgAttachToSprite: true is supported for RPGJS v4 compatibility. Prefer attachToSprite: true in v5 GUI configuration.
Injections
Vue components can inject:| Injection | Description |
|---|---|
engine / rpgEngine | RpgClientEngine instance |
socket / rpgSocket | WebSocket access |
gui / rpgGui | RpgGui service |
rpgScene | Function returning the current client scene |
rpgStage | PIXI stage when available |
rpgResource | { spritesheets, sounds } |
rpgObjects | Observable of scene players and events |
rpgCurrentPlayer | Observable of the current player |
rpgGuiClose | Close a GUI and notify the server |
rpgGuiInteraction | Send a GUI action to the server |
rpgKeypress | Observable of mapped keypresses |
rpgSound | Sound helper with get(id) and play(id) |
Vue Directives
Usev-propagate on an element when events inside a Vue GUI must also be sent to the RPGJS canvas:
#rpg canvas.
Behavior Notes
- Vue and CanvasEngine GUI components share
RpgGui.display(),RpgGui.hide(),player.gui(id).open(), and GUI interactions. - CanvasEngine attached GUI components render in
character.ce. - Vue attached GUI components render in the DOM overlay and are kept out of the CanvasEngine renderer.
- Signal dependencies and
autoDisplayare supported for Vue GUI entries.