Skip to main content

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

Backends

Not sure which to use? See Choosing a backend.