Skip to main content
userTourKit
@tour-kit/surveysUtilities

Utilities

Standalone scoring functions — calculateNPS, calculateCSAT, calculateCES — that work in React components, server actions, and analytics pipelines

domidex01Published

Three pure functions for scoring survey responses. They have no React dependencies and can be used anywhere: in server actions, API routes, analytics ingestion pipelines, or inside React components.

Import

import { calculateNPS, calculateCSAT, calculateCES } from '@tour-kit/surveys';

Available utilities

Within React components

Use useSurveyScoring to access these functions inside a SurveysProvider:

import { useSurveyScoring } from '@tour-kit/surveys';

function Results() {
  const { getSurveyScore } = useSurveyScoring();
  const result = getSurveyScore('nps-q1'); // auto-selects algorithm
}

Outside React

import { calculateNPS } from '@tour-kit/surveys';

// In a server action or API route
const nps = calculateNPS([9, 10, 6, 7, 8, 10, 4]);
console.log(nps.score); // e.g. 14
Free & open source

Ship onboarding, not config.

npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.

MIT-licensed — no signup, no credit card. Pay once, only when you ship.