React query builder

A typed React query builder. Rules, groups, drag and drop, undo, validation, and export to SQL with bound parameters. Editing one rule re-renders one rule.

MIT · React 18+ · SSR-safe · TypeScript

@qnot/react, default builder, live on this page. Edit a rule and watch the exports.

installpnpm add @qnot/core @qnot/react

A React query builder in two files.

The fields you can query, and the component that edits them. It's the code behind the demo above, minus the export tabs.
fields.ts
Filters.tsx

The default <QueryBuilder> is unstyled HTML with a small stylesheet. For more control, create the store with useQueryStore, share it with <QueryProvider>, and read it from anywhere with useQuery, useHistory or useIsValid. Each rule component subscribes to its own node through useRule(id), so a keystroke re-renders one rule, not the tree.

Prefer a designed UI? The coss ui, shadcn/ui and MUI builders are React components built on these hooks.

What you get.

Everything below works in every binding, because it lives in the store, not the components.

How it compares.

The two established React options are react-querybuilder and react-awesome-query-builder. Both are good libraries; here is where each one fits, measured with the same 1,000-rule tree.

Questions people ask

Is it free?
Yes. qnot is MIT licensed, the core and every binding. There is no paid tier, no license key and no API key.
Does it work with Next.js and server rendering?
Yes. Render the builder from a client component ('use client'). It server-renders too: the hooks give React the same snapshot on the server, and node ids are sequential per store, so the server HTML matches the client. Your route handlers can import the same fields.ts to validate and run the query.Server usage
Which React versions are supported?
React 18 and later. The hooks are built on useSyncExternalStore.
How is it different from react-querybuilder?
react-querybuilder is older, more widely used, has React Native support and exports to more formats. qnot types rule values by field and operator, runs outside React too, and keeps keystrokes under a millisecond at 1,000 rules where react-querybuilder takes about 57 ms in our benchmark.qnot vs react-querybuilder
Can I keep my saved react-querybuilder or RAQB queries?
Yes. Give the store format: rqb or format: raqb and value / onChange read and write that library's JSON, so stored queries load as they are and keep being saved in the same shape.Migration guide
Can I use my own components or UI kit?
Yes. Swap any piece of the default builder through the components prop, or build your own from the hooks (useGroup, useRule, useNode). Ready-made builders for coss ui, shadcn/ui and MUI install as source with one shadcn command.shadcn/ui builder Custom UI guide