npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

myquizbot-react

v1.0.5

Published

React component library for MyQuizBot - Interactive quiz components with API integration

Downloads

527

Readme

@myquizbot/react

A React component library for embedding interactive quizzes with API integration and event handling.

Installation

npm install @myquizbot/react

Usage

import { Quiz } from '@myquizbot/react';
import '@myquizbot/react/dist/style.css';

function App() {
  return (
    <Quiz
      quizId="procrastinacao"
      apiKey="pk_live"
      mode="steps"
      onStart={(e) => {
        console.log('Quiz started:', e);
      }}
      onAnswer={(e) => {
        console.log('Question answered:', e);
      }}
      onProgress={(e) => {
        console.log('Progress:', e.percentage + '%');
      }}
      onComplete={(e) => {
        console.log('Quiz completed:', e);
      }}
      onError={(e) => {
        console.error('Error:', e.message);
      }}
    />
  );
}

Props

Required Props

| Prop | Type | Description | |------|------|-------------| | quizId | string | Unique identifier for the quiz to load | | apiKey | string | API key for authentication |

Optional Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | mode | 'steps' \| 'single' \| 'flow' | 'steps' | Render mode for the quiz | | baseUrl | string | http://localhost:5003 | Base URL for API calls | | className | string | - | Custom CSS class name | | style | React.CSSProperties | - | Custom inline styles |

Event Handlers

| Handler | Type | Description | |---------|------|-------------| | onStart | (event: QuizStartEvent) => void | Called when the quiz starts | | onAnswer | (event: QuizAnswerEvent) => void | Called when a question is answered | | onProgress | (event: QuizProgressEvent) => void | Called when progress is made | | onComplete | (event: QuizCompleteEvent) => void | Called when the quiz is completed | | onError | (event: QuizErrorEvent) => void | Called when an error occurs |

Event Types

QuizStartEvent

interface QuizStartEvent {
  quizId: string;
  timestamp: number;
}

QuizAnswerEvent

interface QuizAnswerEvent {
  questionId: string;
  answer: any;
  timestamp: number;
}

QuizProgressEvent

interface QuizProgressEvent {
  currentStep: number;
  totalSteps: number;
  percentage: number;
}

QuizCompleteEvent

interface QuizCompleteEvent {
  quizId: string;
  answers: Record<string, any>;
  timestamp: number;
  sessionId?: string;
}

QuizErrorEvent

interface QuizErrorEvent {
  error: Error;
  message: string;
  timestamp: number;
}

Modes

Steps Mode (default)

Displays questions one at a time with a progress bar and navigation.

<Quiz quizId="my-quiz" apiKey="pk_live" mode="steps" />

Single Mode

(Coming soon) Displays all questions on a single page.

Flow Mode

(Coming soon) Displays questions in a visual flow diagram.

Customization

You can customize the appearance using CSS:

/* Override default styles */
.quiz-container {
  max-width: 1000px;
}

.quiz-steps-option {
  background: #your-color;
}

Or pass custom styles via props:

<Quiz
  quizId="my-quiz"
  apiKey="pk_live"
  className="my-custom-quiz"
  style={{ maxWidth: '600px' }}
/>

API Configuration

The component connects to your MyQuizBot backend API. Configure the base URL:

<Quiz
  quizId="my-quiz"
  apiKey="pk_live"
  baseUrl="http://localhost:8080"
/>

Or set it via environment variable:

VITE_API_BASE_URL=http://localhost:8080

Current Backend Integration

The library currently uses the following backend endpoints:

  • GET /core/quiz - Fetches all quizzes (requires authentication)

The component filters the quiz list client-side to find the requested quizId.

Session Management

Note: Quiz sessions are currently managed client-side using localStorage. This means:

  • Session data is stored in the browser
  • Answers are tracked locally
  • No server-side session persistence yet

Recommended Backend Improvements:

For production use, consider adding these endpoints to your backend:

GET  /core/quiz/:id              - Fetch specific quiz by ID
POST /core/quiz/session          - Create new quiz session
POST /core/quiz/session/:id/answer - Submit answer
POST /core/quiz/session/:id/complete - Complete session

This will enable:

  • Server-side session tracking
  • Answer persistence
  • Analytics and reporting
  • Multi-device session continuity

TypeScript Support

The library is written in TypeScript and includes full type definitions. Import types as needed:

import { Quiz, QuizProps, QuizCompleteEvent } from '@myquizbot/react';

License

MIT