How to Create a Web Form of Any Complexity and Add It to Your JavaScript App in Minutes with SurveyJS
Tags: javascript, form, survey, react
Published: 2023-01-09 08:16:13

{% embed https://youtu.be/VKg8KPRYQaU %}
If you are looking for a fast and easy way to automate form workflow in your organization or simply need to create a survey, poll, or quiz and add it to your web application, then [SurveyJS](https://surveyjs.io/) is the way to go. 

SurveyJS lets you configure and run multiple forms for any use case you need to handle, whether it’s a contact form to collect leads from your website, or a product feedback popup to gather useful insights from your customers; with SurveyJS, you can have it all. Or you can go further and build your own self-hosted and secure form management system that lets you decrease the workload of your software developers thanks to an easy-to-use drag-and-drop user interface that doesn’t require any coding knowledge.

In this article, you’ll learn how to get started with SurveyJS, and run a [Product Feedback](https://surveyjs.io/form-library/examples/product-feedback-survey-template/reactjs) survey in your application. 
To get started, let’s head over to [surveyjs.io](https://surveyjs.io/). When you look at the tabs of the top banner, you will see sections for Features, Product overviews, a collection of [over a hundred free demos](https://surveyjs.io/form-library/examples/nps-question/angular) for each product, a dedicated section for developers that contains useful links for product guides, the [Source code](https://github.com/surveyjs), the [Change log](https://surveyjs.io/changelog), and much more.

![Get Started With SurveyJS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ow8fc0fkgprk7etli08.png)


If you click the [Features](https://surveyjs.io/features) tab and scroll down, you will see a visual representation of what SurveyJS libraries are about and how they interact with one another and the database. 

![SurveyJS Product Features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95ev24zhrp2h1btw4s1y.png)

You might be wondering **how SurveyJS is different** from popular SaaS survey platforms that are out there. 
Well, first off, what makes SurveyJS stand out from the rest is that unlike the majority of online survey services, we do not lock you in. **SurveyJS is 100% self-hosted** and it allows you to ensure individual privacy and legal compliance, because all sensitive respondent data is securely stored in your own database, not within a third-party cloud. Let’s take a look at the diagram again!
The SurveyJS project consists of four open-source JavaScript libraries.

The [Form Library](https://surveyjs.io/form-library/documentation/overview) is totally free, MIT-licensed, and it lets you configure dynamic data-driven forms and run them in your web applications using a variety of front-end technologies. Whether you use [React](https://surveyjs.io/form-library/documentation/get-started-react), [Angular](https://surveyjs.io/form-library/documentation/get-started-angular), [jQuery](https://surveyjs.io/form-library/documentation/get-started-jquery), [Vue](https://surveyjs.io/form-library/documentation/get-started-vue), or even [Knockout](https://surveyjs.io/form-library/documentation/get-started-knockout), SurveyJS supports integration with any of them. And SurveyJS is [server- and database-agnostic](https://surveyjs.io/documentation/backend-integration), so you have total freedom here - any combination is fully compatible. 

With the [PDF Generator](https://surveyjs.io/pdf-generator/documentation/overview) library, you can generate fillable PDF forms and save your forms as PDF files for easier and greener form management. 

The [Dashboard](https://surveyjs.io/dashboard/documentation/overview) library allows you to quickly visualize and analyze your survey data with interactive charts and tables.

The fourth library is called [Survey Creator](https://surveyjs.io/survey-creator/documentation/overview), and as the name implies, it lets you design an unlimited number of fully-customizable, complex, multilingual forms in an intuitive and easy-to-use interface. But not only that! With Survey Creator, you can build and self-host your own form management system that any non-technical user such as a content manager can work with.
This brings us to our next important feature: **SurveyJS uses an industry-standard JSON format as a common ground**. Your entire form is defined as a [data model](https://surveyjs.io/form-library/documentation/design-survey/create-a-simple-survey) (a ‘schema’) written in JSON, and the form UI is built automatically from templates using the model. So anytime something needs to be changed, all you do is edit the form in the no-code interface of your own Survey Creator, and its JSON definition file updates automatically. 

But no more talking, you can easily see it in action, because SurveyJS has a free [full-scale demo for Survey Creator](https://surveyjs.io/create-free-survey) that you can play with to make sure it’s got all you need. 
Click “Create a Survey” in the top right corner to start with a form from scratch, or use a ready-to-use template and modify it to add your company logo, add additional questions, rearrange existing ones, and change the template completely!

![Create a Free Online Survey with SurveyJS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9sfinty7hya745zl7dcg.png)

To save time, head over to Demos and under Form Library, select the [Product Feedback Survey demo](https://surveyjs.io/form-library/examples/product-feedback-survey-template/reactjs) and click Edit in Survey Creator. 

![Product Feedback Survey Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7c0a9xujq95wk3m8l99h.png)

The Preview tab lets you see how the form will look. Switch to this tab during the design process to check any changes made to the form.

![Survey Creator: Tabs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1dzgokuq3bc02z0phdr.png)

The Designer tab is where all the magic really happens! Here, you can choose from a variety of form elements that include a Radio button group, a Rating question, Checkboxes, File upload, and more. You can also add a panel to your form, insert several questions into it, and modify them all at once.

![Survey Creator: Toolbar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikuknc4s4ze2ot7b1nvz.png)

The Logic tab is where you define the flow of your survey to make sure your respondents always get the most relevant questions. Take a look at the Preview tab once again. The first question is ‘How did you first hear about us’. If you reply ‘Social media’, an additional question appears asking to specify the platform. 
To set such a conditional rule, you first need to remove the existing one in the Logic tab and click the Add New Rule button:

![Survey Creator: Add New Conditional Rule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqv3upi6z92aw9dseqq9.png)

Now select the main question, which in this case is ‘How did you first hear about us’. Then, choose a condition for the dependent question to appear, which is that the reply ‘equals’ ‘Social media’. If the condition is met, then the question ‘Which platform?’ is shown. Click Done. 

![Survey Creator: Configure a New Logic Rule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frc82twqqodgl8qfqgbu.png)

Let’s go to the Preview tab, select ‘Social media’, and there it is, the follow-up question appears.
While we were configuring our survey, its JSON definition file that represents the survey model or schema is automatically generated for us. 

![Survey Creator: Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgk2epy1hd4vnyvmq9qb.png)

While we were configuring our survey, its JSON definition file that represents the survey model or schema is automatically generated for us.

![Survey Creator: JSON Editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zou0qaiwlb83uijwzj95.png)

Now all you need to do is add the Form Library component to run the form in your application. 
To add the Form Library component to your application, go to the [Documentation](https://surveyjs.io/documentation) and in the left menu under the Form Library, click ‘Get started’ and select your front-end technology to see a step-by-step [getting started guide](https://surveyjs.io/form-library/documentation/get-started). Alternatively, you can simply clone the library repository, install dependencies and open a ready-to-run sample application in your IDE. 

![SurveyJS Form Library: Get Started](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc82ucl338ln75d5omoe.png)

SurveyJS offers over a [hundred free demos](https://surveyjs.io/form-library/examples/nps-question/angular) that you can use. Form Library is completely free, so be sure to add it to your application today. 

***
We hope you enjoyed this article. Should you have any questions, feel free to post a comment below. For technical assistance, reach out to us at <u>support@surveyjs.io</u>.