Configuration
Configuration files describe how a run moves between pages, what components each page renders, and when elements appear. This guide combines the previous Pages, Routing & Actions, and Expressions docs into one reference.
Top-Level Fields
Every config file supports these top-level fields:
| Field | Type | Required | Description |
|---|---|---|---|
schema_version |
string | Yes | Config schema version (currently "0.1.0") |
initialPageId |
string | Yes | The page to start on |
pages |
array | Yes | Page definitions |
agents |
array | No | AI agent definitions (see Agents) |
matchmaking |
array | No | Matchmaking pool configurations |
session_state |
object | No | User state schema with types and defaults |
allowRetake |
boolean | No | Whether completed participants can start a new session (default: false) |
schema_version
Required field for config validation. Currently use "0.1.0":
The CLI's pairit config lint command validates that schema_version is present.
allowRetake
Controls whether participants who have completed the experiment can start a new session:
schema_version: 0.1.0
allowRetake: true # Allow participants to retake
initialPageId: intro
pages:
# ...
When allowRetake: false (default):
- Completed participants see a "You have already completed this experiment" message
- Session resumption still works for in-progress sessions
When allowRetake: true:
- Completed participants can start a fresh session
- Useful for testing or experiments that allow multiple completions
Pages
Pages declare which components appear and which buttons can advance the run. Built-in components cover common UI. For your own UI, use the HTML component.
Common page fields:
id: string, unique within the configend?: boolean; when true, entering the page ends the sessionendRedirectUrl?: string; optionalhttp://orhttps://URL exposed as a "Continue" button on end pages. Participants can follow it to finish in an external system instead of restarting.onEnter?: array of actions to run invisibly when entering the page (e.g., randomization). See Randomization.components?: array of component instances shown on the page (canonical)layout?: set tosplitfor a two-column page (see Split layout)width?: set towidefor a wider single-column page card (max-w-5xlinstead ofmax-w-3xl); default is"default"height?: optional height in pixels forlayout: splitpages when you want the columns taller than the viewport (by default, split pages fill the viewport height)
Component instance shapes:
- Built-in text:
{ type: "text", props: { text: string, markdown?: bool } } - Built-in buttons:
{ type: "buttons", props: { buttons: [ { text: string, action: Action } ] } } - Built-in survey:
{ type: "survey", props: { items: [{ id, text, answer, choices? }] } } - Built-in matchmaking:
{ type: "matchmaking", props: { poolId: string } } - Built-in chat:
{ type: "chat", props: { agents?: string[] } } - Built-in html:
{ type: "html", props: { src: string, read?: string[], write?: string[], height?: number | "auto", borderless?: bool, required?: bool, action?: Action } }
All component instances also accept an optional when field to conditionally render based on session_state (see Expressions).
Split layout
layout: split shows the page in two columns. Set column: left or column: right on a component to choose its column. Components without column follow the defaults:
live-workspacegoes right.buttonsgo below both columns.- Everything else goes left.
pages:
- id: negotiate
layout: split
components:
- type: chat
props:
agents: [dealer]
- type: html
column: right
props:
src: listing.html
- type: buttons
props:
buttons:
- text: Done
action: { type: go_to, target: thanks }
Each column scrolls independently when its content is taller than the column height, so long briefs or surveys in one column can scroll while the other column stays in view.
column has no effect on pages without layout: split.
Example page:
pages:
- id: intro
components:
- type: text
props:
text: "Welcome to the study!"
- type: buttons
props:
buttons:
- id: next
text: "Next"
action: { type: go_to, target: outro }
- id: outro
end: true
endRedirectUrl: "https://app.prolific.com/submissions/complete?cc=ABCD1234"
Participants see the endRedirectUrl only once they reach that page.
Participants and sign-in
- Participants who arrive from Prolific (the link carries
PROLIFIC_PID) skip Google sign-in. Prolific doesn't sign these parameters, so the lab can't verify a PID, and the sign-in requirement doesn't stop someone from posing as a Prolific participant. - A participant who reloads the page continues where they left off. A Prolific participant must continue in the same browser where they started. Opening the link in another browser or device shows "Continue in the browser where you started this study."
- A participant who signed in with Google can continue on any device.
Routing & Actions
Routing advances the participant between pages using button actions. Use conditional branches to route based on state or the triggering event.
Core actions:
go_to: move to a target page idnext: advance to the next page when using linear flowsend: mark the session ended
Conditional routing with branches:
pages:
- id: sleep_q
components:
- type: text
props:
text: "How many hours did you sleep last night?"
- type: survey
props:
items:
- id: sleep_hours
text: "Hours slept"
answer: numeric
- type: buttons
props:
buttons:
- id: submit_sleep
text: "Submit"
action:
type: go_to
branches:
- when: "session_state.sleep_hours < 5"
target: short_sleep_followup
- target: outro
- id: short_sleep_followup
components:
- type: text
props:
text: "We're sorry to hear that. Can you tell us what woke you up?"
- type: buttons
props:
buttons:
- id: continue
text: "Continue"
action: { type: go_to, target: outro }
- id: outro
end: true
Expressions
Use expressions to conditionally render components and route between pages. Expressions evaluate with a safe expr-eval subset.
The expression evaluator currently supports session_state.{key} {op} {value} patterns, including nested dotted paths like session_state.chat.messages_sent >= 3.
Context roots available:
session_state-- participant-scoped state fieldsgroup-- what the participant may see about their matched group:group.others.0.<key>andgroup.ws.<field>. See Share answers with the group.
Planned (not yet implemented):
event,env,now,run
Whitelisted functions:
floor,ceil,roundand,or,notincludes,lower,upper,trim
Planned (not yet implemented):
min,max,abs,coalesce,len,rand
Example component-level conditional rendering:
pages:
- id: sleep_q
components:
- type: text
props: { text: "How many hours did you sleep last night?" }
- type: survey
props:
items:
- id: sleep_hours
text: "Hours slept"
answer: numeric
- type: text
when: "session_state.sleep_hours < 5"
props: { text: "We're sorry to hear that. Can you tell us what woke you up?" }
Data store
Declare a session_state schema to describe the participant-scoped fields your run uses. The compiler validates assignments against this schema and wires default values into the initial session state.
session_state:
age: int
consent: bool
sleep_hours:
type: int
default: 8
survey_answers:
type: object
properties:
q1: { type: string }
q2: { type: integer }
additionalProperties: true
Guidelines:
- Primitive aliases (int, bool, string) map to JSON Schema types; expand to objects when you need nested data.
- Use default to seed initial values.
- Set additionalProperties: false on objects unless you expect dynamic keys.
At runtime access the store through the UserStoreContext helpers:
const { state, assign, bulkAssign } = useUserStore();
await assign('sleep_hours', 6);
await bulkAssign({
consent: true,
survey_answers: { q1: 'text response' },
});
Assignments outside session_state.* are rejected during validation. Surveys automatically write answers into the store using their question ids, so follow-up expressions can branch on the captured values.