Modules
Authentication
Players sign in to a game, not to Ansekai. Every game has its own players.
Ways to sign in
Open Authentication in the panel and add the ways players may use:
| Method | What the player does |
|---|---|
| Email and password | Signs up with an email and a password of 8 to 128 characters |
| Guest | Starts at once without an account. With email and password on, a guest can add them later and keep everything |
A game without any method on can't sign anyone in. Turning a method off keeps the accounts, they just can't use it until it is back.
await ansekai.auth.register("player@example.com", "a good password");
await ansekai.auth.login("player@example.com", "a good password");
// A guest keeps its id when it adds an email later
await ansekai.auth.guest();
await ansekai.auth.upgrade("player@example.com", "a good password");auth.onChange hears every sign in and sign out, auth.currentPlayer is the player of this device without asking the server. The SDK keeps the session on the device, localStorage in a browser.
Tokens
A signed in player gets a token, the SDK sends it with every call. The Tokens tab of the settings of Authentication picks its type and how long it lasts:
| Type | When to use it |
|---|---|
| Opaque | Random text only this server can read. The safe default |
| JWT (HS256) | Holds the player inside, signed with a secret of this server |
| JWT (EdDSA) | Your own game servers check it with the public key shown in the panel |
| PASETO v4 | Like JWT (EdDSA) with a stricter format |
A token lasts 0 to 3650 days, 0 means it never ends. A change counts for new sign ins, tokens that are already out keep their type and their end. An ended token answers token_expired, the player signs in again.
Players in the panel
The Users tab lists the players of the game. From a row you can:
- Reset password: gives a new password that is shown once, every session of the player ends.
- Reset sessions: signs the player out on every device.
- Delete: the player and its sessions are gone for good.
Hooks
A plugin can run when a player signs up or signs in, see Plugins.
ansekai.on("player.registered", function(ctx, event)
ansekai.data.set(event.player, "gold", 20)
end)Updated November 21, 2026