Use a game with Studio
UseprovideStudioGame when the current RPGJS game should load its maps, database, media references, and player start configuration from RPGJS Studio data.
Install the package
Studio mode
In Studio mode, the game reads data from RPGJS Studio. AddprovideStudioGame to both the client and server configurations and pass the Studio project identifier.
Client configuration:
projectId is set, the runtime uses online Studio data by default.
Studio hotbar settings
createStudioActionBattlePreset() connects the Action Battle hotbar to the
Studio project and map menu settings:
menus.hotbar:
guiId: null selects the native RPGJS GUI. Inside settings, content is
skills, items, or mixed, and slotCount is between 1 and 10. A map can
persist the same complete binding to override the project. A map without
menus.hotbar inherits the project configuration. The preset opens or closes
the hotbar on map changes, filters its allowed entries, and preserves
temporarily hidden player assignments.
MMORPG mode
Studio MMORPG maps use an authoritative, chunked data path:- a trusted publisher loads and normalizes the complete Studio map, project, database, events, and collisions;
- the Node server or Cloudflare Durable Object stores that authoritative payload, runs physics and events, and decides which chunks surround each player;
- the browser receives only the nearby render descriptors and collision barriers required for display and client prediction.
chunkSize is expressed in Studio cells. loadRadius controls the chunks sent
around the authoritative player position, while retainRadius keeps a slightly
larger client cache to avoid loading churn at chunk boundaries. NPCs, events,
players, and projectiles continue to use the generic RPGJS spatial synchronization
path and are disclosed according to server interest management.
Client prediction remains enabled with Studio. Movement is predicted against
the collision barriers already disclosed for the active chunks, blocked at the
edge of the streamed window, then reconciled with authoritative Node or Durable
Object snapshots. Event behavior, NPC decisions, projectile impacts, and every
collision outside that window remain server-authoritative.
Live map updates from Studio
Players must never publish map definitions. Studio, Vite, CI, an editor backend, or another trusted process sends the full payload to the map room:Authorization: Bearer <secret> is also accepted. Configure
RPGJS_MAP_UPDATE_TOKEN only on the Node server or Worker. Never put it in browser
code or in a VITE_ environment variable.
Map content and world topology are separate authoritative updates. After
publishing a prepared map, the trusted publisher sends the current topology to
every map room in that world:
marsh, for example,
does not update a player who is still connected to port.
The easiest development publisher is the RPGJS Vite plugin:
createStudioMapUpdatePayload() supplies worldUpdates, and the RPGJS remote
publisher automatically sends them to every referenced map room.
To test the HTTP contract directly, send a previously prepared Studio v2 payload:
/map/update replaces the authoritative map
revision. Use createStudioMapUpdatePayload() rather than assembling production
payloads by hand. Its result includes the normalized v2 render data, dimensions,
server collisions, events, project configuration, and database records needed by
the room. This direct curl updates only one map revision; it does not perform
the world fan-out. Use the RPGJS publisher or the Studio seed command for a full
map-and-world publication.
Trusted publisher data provider
A trusted backend that already owns the Studio project data can inject aGameDataProvider and avoid calling the public Studio API while preparing an
MMORPG map update:
dataProvider is omitted, the existing
online, offline, and auto runtime modes keep selecting the built-in provider.
For a runnable local Worker, deterministic fixture, seed script, and real Studio
API seed command, see the
Studio playground.
Offline mode
Offline mode lets the game run from exported Studio data without calling the Studio API. Export the project data from Studio into the game public directory, using the default bundle path:provideStudioGame without projectId, or force runtimeMode to "offline":
/game-data. Use bundleBasePath only if the exported folder is served from another path:
spCost, hitRate, power, and coefficient fields, and enemies can learn skills referenced by their skills array.
The project can define hero skill progression with skills or skillsToLearn. At runtime, provideStudioGame() creates a default RPGJS class containing those entries, then RPGJS learns each skill when the configured level is reached:
player.onSkillChange hook and displays a notification when the hero learns or forgets a skill.
Enemy records can also drive action-battle AI. Use behavior on the enemy to set fields such as enemyType, behaviorKey, visionRange, attackRange, attackCooldown, dodgeChance, dodgeCooldown, fleeThreshold, attackPatterns, patrolWaypoints, groupBehavior, or the nested behavior gauge options. The older aiBehavior field is still accepted as a compatibility alias. Every learned enemy skill is evaluated from its action mode, targeting range, area mask, SP cost, and cooldown. attackSkillId gives one skill priority without disabling normal attacks or the other learned skills.
Skill workflow triggers
Studio skills may declareworkflowTriggers that reference Studio block
collections:
onUse
hook. It does not add a second engine hook. Studio preserves the default skill
effect, waits for projectile impact when applicable, then executes the blocks
from the referenced collection. The block context exposes the caster as the
player and the affected map event as the current event when one exists. A skill
workflow can call or spawn Common Events through the corresponding blocks.
Item workflow triggers
Studio item records expose fields and workflow phases according to their item type:- regular items expose
hpValue,mpValue,hitRate,consumable,onAdd,onUse,onUseFailed, andonRemove; - weapons and armors expose their equipment statistics, parameter modifiers,
onAdd,onRemove, andonEquip; - weapons and armors do not expose
consumable,onUse, oronUseFailed.
hitRate is edited as a percentage from 0 to 100 and normalized to the
native RPGJS hitRate value from 0 to 1. An equipment onEquip workflow can
test variables.equip: it is true after equipping and false after
unequipping.
enemy-id::2 to later placements, while preserving sourceEventId for
database lookups. Each placement therefore gets its own sprite, hitbox, HP,
Battle AI state, and defeat lifecycle.
Built-in GUI settings
Studio projects can bind the native Title Screen, Hotbar, HUD, and Main Menu roles. Anull guiId selects the built-in RPGJS component and leaves room
for a future Studio GUI definition:
set_hotbar block to display it with skills, items, or mixed content and
1 to 10 slots, or to hide it without clearing persistent assignments.
Auto mode
Use"auto" when the game should try the exported bundle first, then fall back to Studio if local data is missing:
Start without a title screen
UseautoStart when the player should enter the starting map as soon as the
server connection is established:
startMapId or to the starting map defined by the Studio project.
autoStart defaults to false, so games using the title-screen start
interaction keep their existing behavior. displayTitleScreen controls only
the client display and does not enable immediate startup by itself.
Options
projectId: Studio project identifier. When provided, the default runtime mode is"online".runtimeMode: data loading strategy. Use"online","offline", or"auto".bundleBasePath: public path for exported Studio data. Defaults to/game-data.displayTitleScreen: display the Studio title screen when supported by the project.autoStart: initialize the player and enter the starting map immediately on connection. Defaults tofalse.
menus.titleScreen.enabled: false; the
Studio runtime then enables immediate startup automatically. Explicit
autoStart remains useful for non-Studio configuration and overrides.
startMapId: force the map used to start the player.streaming: authoritative Studio v2 chunk settings for MMORPG mode. Set it tofalseonly when another server map provider replaces the built-in streaming adapter. Standalone mode always uses the direct loader. Its options arechunkSize,loadRadius, andretainRadius.debugCollisions: display Studio collision debug overlays. This is a shortcut for the built-in Studio debug plugin.studioPlugins: attach Studio client-side map renderer plugins. See Create a Studio plugin.