A lightweight, minimal dependency Next.js implementation of the A/B AI Trust experiment.
- Next.js/React: Built securely using standard Next.js constraints.
- Short Codebase: codebase only within 4 files (
layout.tsx,page.tsx,globals.css,package.json). - Low Dependencies: No heavy frontend libraries like Tailwind or framer-motion. Just React and Next frameworks.
- A/B Logic: Randomly assigns users(participants) with a recommendation as Condition A (Technical) or Condition B (Warm/Friendly).
- High-Resolution Latency Logging: Uses
performance.now()to measure click latency to the nearest millisecond. - Data Export: Logs all required parameters -
participant_id,condition,decision,timestamp,latency_msas structured JSON, downloaded immediately on decision, exactly as specified. - AI Recommendation Ready: Includes a commented-out API block (e.g., Groq/OpenAI) for dynamically fetching generated recommendations based on either Condition A (Technical) or Condition B (Warm/Friendly); maintaining the prompt structure with a system prompt.
- Condition A (Technical) - recommendation framed with precise, data-driven language
- Condition B (Warm/Friendly) - same recommendation framed in conversational, empathetic language
Assignment is done client-side on page load. Each participant sees only one condition.
{
"participant_id": "f3a2c1d4-8e6b-4a2f-9c1e-7d5b3f2a1e8c",
"condition": "B",
"decision": "accepted",
"timestamp": "2026-03-28T14:22:31.408Z",
"latency_ms": 3421
}- Install dependencies:
npm install- Start the development server:
npm run dev- Open localhost
Check app/page.tsx for a commented-out standard fetch block utilizing Groq (https://api.groq.com/openai/v1/chat/completions) or any LLM compatible schema. You can use any APIKey endpoint to inject generative messaging by un-commenting the code.