Skip to content

Getting Started

Overview

Filter Sphere is a library for building filtering interfaces. It provides a set of components that you can use to build your own filtering interface.

Usage Summary

  1. Install the Filter Sphere package using your favorite package manager:

    Terminal window
    pnpm add @fn-sphere/filter
  2. Filter Sphere uses zod to define your data schema. If not installed, run the following command:

    Terminal window
    pnpm add zod
  3. Define your data with zod. For example

    const YOUR_DATA_SCHEMA = z.object({
    id: z.number(),
    name: z.string(),
    });
  4. Start building your filtering interface with Filter Sphere components.

    import {
    FilterSphereProvider,
    FilterBuilder,
    useFilterSphere,
    } from "@fn-sphere/filter";
    import { z } from "zod";
    // Define your data schema
    const schema = z.object({
    id: z.number(),
    name: z.string(),
    });
    export default function AdvancedFilter() {
    const { filterRule, predicate, context } = useFilterSphere({ schema });
    return (
    <FilterSphereProvider context={context}>
    <FilterBuilder />
    </FilterSphereProvider>
    );
    }

Next Steps