survey-react-ui is a free, MIT-licensed React UI component library designed to render dynamic, interactive JSON-based forms and surveys directly within React applications. It enables developers to easily design and deploy complex, data-driven forms, polls, and quizzes, collecting user responses. The package is currently at version 2.5.20 and follows a rapid release cadence, with frequent minor and patch updates as indicated by the successive 2.5.x versions. Key differentiators include a rich set of over 20 built-in question types, support for custom question types, integrated themes with extensive CSS customization options, robust answer validation, and comprehensive TypeScript support. It is built upon `survey-core` for its underlying survey model logic and is broadly compatible with React versions 16.5, 17, 18, and 19. The library is backend-agnostic, with provided examples for Node.js, PHP, and ASP.NET environments.
npm install survey-react-uiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a SurveyJS `Model` from a JSON definition and render it using the `Survey` React component. It includes basic state management for displaying results after completion and highlights the necessary CSS import for styling.
Consult the official SurveyJS migration guides (e.g., 'Migrate from v1 to v2') for detailed instructions on updating your JSON, component usage, and custom logic.
Always import core classes like `Model` and `StylesManager` from `survey-core`. For example: `import { Model } from 'survey-core';`.Ensure you import a SurveyJS theme stylesheet in your application, typically in your main component or entry file. For example: `import 'survey-core/defaultV2.min.css';` or `import 'survey-core/modern.min.css';`.
Verify that your project's `react` and `react-dom` versions satisfy the peer dependency requirements of `survey-react-ui`. Update your React versions if necessary, or consider using a compatible version of `survey-react-ui`.
Ensure you pass the `Survey.Model` instance to the `model` prop of the `<Survey />` component: `<Survey model={mySurveyModel} />`. Do not try to render `{mySurveyModel}` directly.Use the correct ES Module named import: `import { Survey } from 'survey-react-ui';`. If using CommonJS, ensure your bundler handles it correctly, or use `const { Survey } = require('survey-react-ui');` (though ESM is recommended).Verify the exact path and filename for the desired SurveyJS theme. For v2, common paths are `survey-core/defaultV2.min.css` or `survey-core/modern.min.css`. Update your import statement accordingly.