@vojtechportes/react-query-builder
v1.8.1
Published
Simple, highly configurable query builder for react
Downloads
2,462
Maintainers
Readme

React Query Builder is a TypeScript library for building nested filter editors, formatting them into external query syntaxes, and parsing supported expressions back into builder state.
Full documentation, API reference, and the interactive demo are available on the project website:
Installation
npm install @vojtechportes/react-query-builderReact Query Builder supports React 18+.
Example
import React, { useState } from 'react';
import {
Builder,
type DenormalizedQuery,
type IBuilderFieldProps,
} from '@vojtechportes/react-query-builder';
const fields: IBuilderFieldProps[] = [
{
field: 'STATE',
label: 'State',
type: 'LIST',
operators: ['EQUAL', 'NOT_EQUAL'],
value: [
{ value: 'CZ', label: 'Czech Republic' },
{ value: 'SK', label: 'Slovakia' },
],
},
{
field: 'IS_IN_EU',
label: 'Is in EU',
type: 'BOOLEAN',
},
];
const initialData: DenormalizedQuery = [
{
type: 'GROUP',
value: 'AND',
isNegated: false,
children: [
{
field: 'IS_IN_EU',
operator: 'EQUAL',
value: true,
},
],
},
];
export const MyBuilder = () => {
const [data, setData] = useState(initialData);
return <Builder fields={fields} data={data} onChange={setData} />;
};Query Conversion
The library also provides parser and formatter helpers through subpath exports:
@vojtechportes/react-query-builder/formatQuery@vojtechportes/react-query-builder/parseQuery
Supported formats are documented on the website:
