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

@survey-kit/core

v0.1.10

Published

Core survey framework for rendering surveys for Survey-Kit.

Readme

@survey-kit/core

Core survey engine for rendering surveys from JSON configuration.

Overview

The core package provides the essential logic and components for building surveys:

  • Survey renderersSurveyRenderer (form-based) and ChatSurveyRenderer (conversational)
  • Layout rendererLayoutRenderer handles page layout, sidebar, and navigation
  • State managementuseSurvey hook for survey state, navigation, validation, and progress
  • Type definitions – TypeScript types for survey and layout configuration
  • Validation – Built-in validation with cross-question support
  • Conditional logic – Show/hide questions and pages based on answers
  • Navigation – Configurable navigation rules (sequential or free-form)

Features

  • Full TypeScript support
  • Conditional logic and skip logic (shouldShowQuestion, shouldShowPage, etc.)
  • Advanced validation (including cross-question validation)
  • Hierarchical survey structure (stages → groups → pages → questions)
  • Progress tracking at multiple levels (page, group, stage, overall)
  • Answer persistence via localStorage
  • Multi-Survey Support – Configure multiple distinct surveys with shared routing
  • Section Layouts – Configure headers and footers for individual section pages
  • Mobile-first, accessible design

Installation

npm install @survey-kit/core

Usage

Form-Based Survey

import { SurveyRenderer, LayoutRenderer } from '@survey-kit/core'
import type { SurveyConfig } from '@survey-kit/core'

const config: SurveyConfig = {
  id: 'my-survey',
  title: 'My Survey',
  stages: [
    {
      id: 'stage-1',
      groups: [
        {
          id: 'group-1',
          pages: [
            {
              id: 'page-1',
              questions: [
                {
                  id: 'q1',
                  type: 'text',
                  label: 'What is your name?',
                  required: true,
                },
              ],
            },
          ],
        },
      ],
    },
  ],
}

function MySurvey() {
  return (
    <LayoutRenderer
      layoutConfig={layout}
      surveyConfig={config}
      components={components}
    >
      <SurveyRenderer
        config={config}
        components={components}
        onSubmit={handleSubmit}
      />
    </LayoutRenderer>
  )
}

Chat-Based Survey

import { ChatSurveyRenderer } from '@survey-kit/core'

function MyChatSurvey() {
  return (
    <ChatSurveyRenderer
      config={config}
      components={chatComponents}
      onSubmit={handleSubmit}
      typingDelay={{ min: 600, max: 1200 }}
    />
  )
}

Survey Configuration Hierarchy

Survey
├── Stages (optional navigation sections)
│   ├── Groups (logical groupings)
│   │   ├── Pages (one page = one screen)
│   │   │   └── Questions (individual form fields)

Question Types

  • text – Single-line text input
  • textarea – Multi-line text input
  • radio – Single select from options
  • checkbox – Multi-select from options
  • select – Dropdown selection
  • emoji-slider – Visual rating scale with emojis

Key Question Properties

{
  "id": "unique-id",
  "type": "text|radio|checkbox|select|emoji-slider",
  "label": "Question text",
  "description": "Optional helper text",
  "placeholder": "Input placeholder",
  "options": [{ "value": "x", "label": "X" }],
  "required": true,
  "requiredToNavigate": true,
  "showWhen": { "questionId": "other-q", "equals": "value" }
}

Core APIs

useSurvey Hook

Manages survey state including:

  • Answers{ [questionId]: { value, touched, valid } }
  • Navigation – Current page, stage, group tracking
  • Validation – Per-question and page-level validation
  • Progress – Completion percentage calculation (progress, stageProgress, groupProgress, overallProgress)
  • Persistence – localStorage for answer recovery
const {
  state,
  currentPage,
  progress,
  setAnswer,
  nextPage,
  prevPage,
  submitSurvey,
} = useSurvey({ config, onSubmit })

Components

  • SurveyRenderer – Traditional form-based survey renderer
  • ChatSurveyRenderer – Chat/messaging-style survey renderer
  • LayoutRenderer – Wrapper component for survey layout (header, footer, sidebar)

Conditional Logic Utilities

  • shouldShowQuestion – Determine if a question should be displayed
  • shouldShowPage – Determine if a page should be displayed
  • shouldShowGroup – Determine if a group should be displayed
  • shouldShowStage – Determine if a stage should be displayed
  • evaluateCondition – Evaluate a single condition
  • evaluateConditions – Evaluate multiple conditions with logic operators

Validation Utilities

  • Built-in validation rules (required, min/max length, pattern matching)
  • Cross-question validation support
  • Custom validation functions

Config Utilities

  • normaliseSurveyConfig – Normalise survey configuration
  • getAllPages – Get all pages from a survey config
  • findPageById – Find a page by ID
  • getPageLocation – Get the location of a page (stage, group, page)

Key Exports

Components

  • SurveyRenderer – Form-based survey renderer
  • ChatSurveyRenderer – Chat-based survey renderer
  • LayoutRenderer – Layout wrapper component

Hooks

  • useSurvey – Survey state management hook

Types

  • SurveyConfig, SurveyPage, SurveyQuestion, SurveyStage, SurveyGroup
  • SurveyState, QuestionAnswer, QuestionType
  • LayoutConfig, SectionConfig, SectionLayout
  • ValidationRule, Condition, ConditionalLogic

Utilities

  • Conditional logic: shouldShowQuestion, shouldShowPage, shouldShowGroup, shouldShowStage, evaluateCondition, evaluateConditions
  • Config utilities: normaliseSurveyConfig, getAllPages, findPageById, getPageLocation

Requirements

  • React 19+
  • @survey-kit/registry (peer dependency)

Licence

MIT