jsPsych Multiplayer runs experiments where participants interact.
Two or more people take part in the same session and see each other's choices: an ultimatum game, a public-goods game, a group chat, a shared drawing, a reference game.
These are ordinary jsPsych plugins. You keep your stimuli, your other plugins and your data pipeline, and add a few trials that wait for the group or show what others are doing.
Try it in two tabs
Build a two-player experiment in one HTML file and play both sides from two tabs of your browser. No server and no account.
Start from a working game
Chat rooms, polls, matching, a public-goods game, a tangram reference game and more, each a single file you can copy.
What it does
Waiting for the group
A trial shares a value, such as an offer, then waits until the group meets a condition, such as the partner having replied. Lobbies, role assignment, pairing and simultaneous choices are each one trial.
Live interaction
Chat, a shared canvas and a director–matcher reference game update on every screen as participants act. Everything they send is recorded in the trial data.
Any backend
Develop in two browser tabs, then collect data through JATOS or Firebase. The backend is one line of your experiment, and nothing else changes when you swap it.
Example
A lobby and two roles
Connect a backend before the timeline runs. After that, multiplayer trials go in your timeline like any other: here, a lobby that waits for two people, then a trial that makes one the proposer and the other the responder.
Build the full game →const jsPsych = initJsPsych();
const lobby = {
type: jsPsychMultiplayerSync,
wait_for: (group, presence) =>
Object.values(presence).filter((p) => p === "connected").length >= 2,
message: "Waiting for a partner…",
};
const roles = {
type: jsPsychMultiplayerRole,
roles: ["proposer", "responder"],
group_size: 2,
};
jsPsych.multiplayer
.connect(new jsPsychAdapterMultiplayerLocal())
.then(() => jsPsych.run([lobby, roles /* , your trials */]));
Plugins
- multiplayer-syncShare a value, then wait until the group meets a condition.
- multiplayer-readyA ready button that holds everyone until the group has checked in.
- multiplayer-roleAssign roles, the same on every screen.
- multiplayer-matchSplit the group into pairs or other sub-groups.
- multiplayer-choiceEveryone chooses at once, then sees what the others chose.
- multiplayer-scoreboardRank every player's final score.
- multiplayer-countdownOne timer, in step on every screen.
- multiplayer-chatA live chat room.
- multiplayer-drawA shared drawing canvas.
- multiplayer-reference-gameA director–matcher reference game, such as tangrams.
Backends
- adapter-multiplayer-localTabs in one browser. For building and testing; no server.
- adapter-multiplayer-jatosJATOS group studies, on your lab's JATOS server.
- adapter-multiplayer-firebaseFirebase Realtime Database. Cross-device, with no server to run.
Not sure which to use? See Choosing a backend.