Skip to content
On this page

Save the player's progress

It is necessary to know

  • The goal is to save the player's status and put the data in the database of your choice (SQL, NoSQL, LocalStorage (for browser), etc.).


Two methods will be necessary:

Example (with axios request)

Add a file in main/server/events/npc.ts

import { RpgEvent, EventData, RpgPlayer } from '@rpgjs/server'

    name: 'EV-1'
export default class CharaEvent extends RpgEvent {
    onInit() {
    async onAction(player: RpgPlayer) {
        const choice = await player.showChoices('Do you whant save your progress?', [
            { text: 'Yes', value: true },
            { text: 'No', value: false }
        if (choice.value) {
            const json =
            try {
                await'https://my-backend-game/save', {
                    data: json,
                    playerId: 123 // An identifier that you must have defined when the player was loaded in the game (be careful, do not use which changes every time you log in)
                player.showNotification('Your progress has been saved')
            catch (err) {
                player.showNotification('Save failed')

See Create Event to add event in map


You decide when you want to save the player's game.

If you want screens to save or load a game, use the following plugins: