react-querybuilder vs @react-awesome-query-builder/ui
Query Builder Libraries for React Comparison
1 Year
react-querybuilder@react-awesome-query-builder/uiSimilar Packages:
What's Query Builder Libraries for React?

Query Builder Libraries for React are specialized components that allow users to create complex queries through a visual interface. These libraries provide a set of tools to build queries dynamically, often using a drag-and-drop interface or a form-based approach. They are particularly useful for applications that need to filter, sort, or search data based on multiple criteria, such as dashboards, data management systems, and content management platforms. By enabling users to construct queries without writing code, these libraries enhance usability and accessibility, making it easier to interact with data. @react-awesome-query-builder/ui is a highly customizable and feature-rich query builder for React that supports complex queries, nested conditions, and a wide range of field types. It offers a modern UI, drag-and-drop functionality, and extensive API for integration. react-querybuilder is a lightweight and simple query builder for React that focuses on ease of use and quick integration. It provides a straightforward interface for building queries with basic support for nested conditions and customizable components, making it suitable for projects that require a simple and efficient solution without a steep learning curve.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-querybuilder81,1791,4977.32 MB2425 days agoMIT
@react-awesome-query-builder/ui77,2762,1131.33 MB12916 days agoMIT
Feature Comparison: react-querybuilder vs @react-awesome-query-builder/ui

Customization

  • react-querybuilder:

    react-querybuilder provides basic customization capabilities, such as styling and the ability to change field types and operators. However, it is more limited compared to @react-awesome-query-builder/ui in terms of extensibility and customization options, making it better suited for projects that do not require deep customization.

  • @react-awesome-query-builder/ui:

    @react-awesome-query-builder/ui offers extensive customization options, allowing developers to modify almost every aspect of the query builder, including the UI, field types, operators, and rules. It supports custom renderers, themes, and plugins, making it highly adaptable to different use cases and design requirements.

Complexity and Learning Curve

  • react-querybuilder:

    react-querybuilder is designed to be simple and intuitive, with a low learning curve. Its straightforward API and minimal setup make it easy for developers to integrate and use quickly, making it a good choice for projects with tight deadlines or less experienced teams.

  • @react-awesome-query-builder/ui:

    @react-awesome-query-builder/ui has a steeper learning curve due to its rich feature set and extensive customization capabilities. Developers may need to invest time in understanding its API and how to implement advanced features, especially for complex use cases.

Performance

  • react-querybuilder:

    react-querybuilder is lightweight and performs well, making it suitable for applications that require quick and responsive query building without significant performance concerns. Its simplicity helps keep resource usage low, even with multiple instances.

  • @react-awesome-query-builder/ui:

    @react-awesome-query-builder/ui is optimized for performance, but its complexity and feature richness may introduce some overhead, especially when handling very large datasets or highly nested queries. However, it is generally efficient and performs well for most use cases.

Documentation and Community Support

  • react-querybuilder:

    react-querybuilder offers good documentation, but it may not be as extensive as that of @react-awesome-query-builder/ui. The community is smaller, which may result in fewer resources and examples available online.

  • @react-awesome-query-builder/ui:

    @react-awesome-query-builder/ui has comprehensive documentation that covers its features, API, and customization options. It also has an active community, which can be helpful for getting support and finding examples.

Code Example

  • react-querybuilder:

    Example of react-querybuilder

    import React from 'react';
    import { QueryBuilder } from 'react-querybuilder';
    
    const App = () => {
      const fields = {
        name: 'Name',
        age: 'Age',
        isActive: 'Is Active',
      };
    
      return (
        <div>
          <h1>Simple Query Builder</h1>
          <QueryBuilder fields={fields} />
        </div>
      );
    };
    
    export default App;
    
  • @react-awesome-query-builder/ui:

    Example of @react-awesome-query-builder/ui

    import React from 'react';
    import { QueryBuilder } from '@react-awesome-query-builder/ui';
    import '@react-awesome-query-builder/ui/dist/style.css';
    
    const config = {
      fields: {
        name: {
          label: 'Name',
          type: 'text',
          operators: ['equal', 'not_equal'],
        },
        age: {
          label: 'Age',
          type: 'number',
          operators: ['greater', 'less'],
        },
        isActive: {
          label: 'Is Active',
          type: 'boolean',
          operators: ['equal'],
        },
      },
    };
    
    const App = () => {
      return (
        <div>
          <h1>Query Builder</h1>
          <QueryBuilder config={config} />
        </div>
      );
    };
    
    export default App;
    
How to Choose: react-querybuilder vs @react-awesome-query-builder/ui
  • react-querybuilder:

    Choose react-querybuilder if you need a lightweight and easy-to-use query builder that provides basic functionality with minimal setup. It is suitable for projects that require a simple solution for building queries without the need for extensive customization or advanced features.

  • @react-awesome-query-builder/ui:

    Choose @react-awesome-query-builder/ui if you need a highly customizable and feature-rich query builder that supports complex queries, nested conditions, and a wide range of field types. It is ideal for applications that require advanced querying capabilities and a modern, intuitive interface.

README for react-querybuilder

react-querybuilder

The Query Builder component for React

React Query Builder is a fully customizable query builder component for React, along with a collection of utility functions for importing from, and exporting to, various query languages like SQL, MongoDB, and more.

Screenshot

Basic usage

npm i react-querybuilder
# OR yarn add / pnpm add / bun add
import { useState } from 'react';
import { Field, QueryBuilder, RuleGroupType } from 'react-querybuilder';
import 'react-querybuilder/dist/query-builder.css';

const fields: Field[] = [
  { name: 'firstName', label: 'First Name' },
  { name: 'lastName', label: 'Last Name' },
  { name: 'age', label: 'Age', inputType: 'number' },
  { name: 'address', label: 'Address' },
  { name: 'phone', label: 'Phone' },
  { name: 'email', label: 'Email', validator: ({ value }) => /^[^@]+@[^@]+/.test(value) },
  { name: 'twitter', label: 'Twitter' },
  { name: 'isDev', label: 'Is a Developer?', valueEditorType: 'checkbox', defaultValue: false },
];

const initialQuery: RuleGroupType = {
  combinator: 'and',
  rules: [],
};

export const App = () => {
  const [query, setQuery] = useState(initialQuery);

  return <QueryBuilder fields={fields} defaultQuery={query} onQueryChange={setQuery} />;
};

Customizations are not limited to the following libraries, but these have first-class support through their respective compatibility packages:

| Library | Compatibility package | Demo | Example projects | | -------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | Ant Design | @react-querybuilder/antd | demo | CodeSandbox · StackBlitz | | Bootstrap | @react-querybuilder/bootstrap | demo | CodeSandbox · StackBlitz | | Bulma | @react-querybuilder/bulma | demo | CodeSandbox · StackBlitz | | Chakra UI | @react-querybuilder/chakra | demo | CodeSandbox · StackBlitz | | Fluent UI | @react-querybuilder/fluent | demo | CodeSandbox · StackBlitz | | Mantine | @react-querybuilder/mantine | demo | CodeSandbox · StackBlitz | | MUI | @react-querybuilder/material | demo | CodeSandbox · StackBlitz | | React Native | @react-querybuilder/native | | CodeSandbox · StackBlitz | | Tremor | @react-querybuilder/tremor | demo | CodeSandbox · StackBlitz |

[!TIP]

To enable drag-and-drop, use @react-querybuilder/dnd.

For enhanced date/time support, use @react-querybuilder/datetime.

Export

To export queries as a SQL WHERE clause, MongoDB query object, or one of several other formats, use formatQuery.

const query = {
  combinator: 'and',
  rules: [
    {
      field: 'first_name',
      operator: 'beginsWith',
      value: 'Stev',
    },
    {
      field: 'last_name',
      operator: 'in',
      value: 'Vai, Vaughan',
    },
  ],
};

formatQuery(query, 'sql');
/*
"(first_name like 'Stev%' and last_name in ('Vai', 'Vaughan'))"
*/

Import

To import queries use parseSQL, parseMongoDB, parseJsonLogic, parseJSONata, parseCEL, or parseSpEL depending on the source.

// Tip: `parseSQL` will accept either a full `SELECT` statement or a `WHERE` clause by itself.
// Everything but the `WHERE` expressions will be ignored.

const query = parseSQL(
  `SELECT * FROM my_table WHERE first_name LIKE 'Stev%' AND last_name in ('Vai', 'Vaughan')`
);

console.log(query);
/*
{
  "combinator": "and",
  "rules": [
    {
      "field": "first_name",
      "operator": "beginsWith",
      "value": "Stev",
    },
    {
      "field": "last_name",
      "operator": "in",
      "value": "Vai, Vaughan",
    },
  ],
}
*/

Utilities

formatQuery, transformQuery, and the parse* functions can be used without importing from react (on the server, for example) like this:

import { formatQuery } from 'react-querybuilder/formatQuery';
import { parseCEL } from 'react-querybuilder/parseCEL';
import { parseJSONata } from 'react-querybuilder/parseJSONata';
import { parseJsonLogic } from 'react-querybuilder/parseJsonLogic';
import { parseMongoDB } from 'react-querybuilder/parseMongoDB';
import { parseSpEL } from 'react-querybuilder/parseSpEL';
import { parseSQL } from 'react-querybuilder/parseSQL';
import { transformQuery } from 'react-querybuilder/transformQuery';

(As of version 7, the parse* functions are only available through these extended exports.)