pico-survey
v1.0.0
Published
Pico Survey: a lightweight, flexible survey orchestration library for React
Maintainers
Readme
Pico Survey
A lightweight, flexible survey orchestration library for React applications.
Installation
npm install pico-survey
# or
yarn add pico-survey
# or
pnpm add pico-surveyQuick Start
import { PicoSurvey } from 'pico-survey';
const MySurvey = () => (
<PicoSurvey
config={{
id: 'my-survey',
pages: [<MyQuestion key="q1" id="q1" title="What's your name?" />],
}}
onComplete={(responses) => console.log('Done!', responses)}
/>
);Package Scripts
Build & Development
yarn build- Build the library (runs type-check first)yarn dev- Watch mode for library developmentyarn build:example- Build the example appyarn dev:example- Start example development serveryarn preview:example- Preview built example app
Testing
yarn test- Run library tests onceyarn test:watch- Run library tests in watch modeyarn test:example- Run example app testsyarn test:example:watch- Run example app tests in watch modeyarn test:all- Run both library and example tests
Type Checking
yarn type-check- Type check the libraryyarn type-check:example- Type check the example app
Code Quality
yarn format- Format code with Biomeyarn format:check- Check code formattingyarn lint- Lint code with Biomeyarn lint:fix- Fix linting issuesyarn check- Format and lint (with fixes)yarn check:ci- Format and lint check (CI mode)
Validation
yarn validate- Type check + code quality check (CI mode)yarn validate:fix- Type check + code quality check (with fixes)
Analysis
yarn analyze- Full bundle analysis (build + size report)yarn analyze:size- Show detailed bundle size report in terminal
Example App Scripts
The example/ directory contains a complete working implementation. Scripts:
yarn dev- Start development serveryarn build- Build for productionyarn preview- Preview production buildyarn test- Run testsyarn test:watch- Run tests in watch modeyarn type-check- Type checkyarn type-check:watch- Type check in watch modeyarn type-check:strict- Type check with strict modeyarn lint- Lint codeyarn lint:fix- Fix linting issuesyarn format- Format codeyarn format:check- Check formattingyarn check- Type check + lint + format checkyarn check:fix- Fix linting and formatting
What's Included
- Survey state management with Zustand
- Navigation and branching logic
- Progress tracking utilities
- TypeScript definitions
- No UI components - you build your own
Features
- Lightweight (core library under 5KB gzipped)
- Flexible question components
- Conditional branching based on responses
- Automatic localStorage persistence
- Section-based progress tracking
- Resume from last question
- Mobile-first optimized
Philosophy
This library handles state, navigation, branching, and persistence. You handle UI, styling, and question components. This separation gives you complete control over the user experience.
Example Implementation
See example/ directory for a complete working survey with:
- Question components (SingleSelect, MultiSelect, Interstitial)
- UI components (SurveyContainer, ProgressBar)
- Survey configurations
- CSS Modules styling
- Comprehensive tests
Run it: cd example && yarn dev
License
MIT
