Skip to content
KajayDocs
IntegrationTypeScript SDKReact

Responses, events, and submission

Read survey data, react to typed lifecycle events, and submit results through your application.

Read and change answers

Read the current response from survey.data. Use setValue or setData for host-driven changes so expressions, validation, and typed events settle exactly as respondent input does.

Subscribe to events

Event subscriptions return an unsubscribe function. Attach them once per survey lifetime and release them when the host component unmounts.

Submit on completion
const parsed = parseSurvey(definition);
const survey = parsed.survey;

const stopValue = survey.onValueChanged.add(({ name, value }) => {
  queueAutosave({ changed: name, value, data: survey.data });
});

const stopComplete = survey.onComplete.add(async ({ data }) => {
  await fetch('/api/responses', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify(data),
  });
});

// When the host component unmounts:
stopValue();
stopComplete();

Submission ownership

  • Kajay decides when the survey reaches completion and emits the final data.
  • The author decides which questions, calculated values, and completion rules exist.
  • The host authenticates the respondent, submits data, handles retries, and records server outcomes.