Beignet API reference
    Preparing search index...

    Module @beignet/nuqs

    @beignet/nuqs

    nuqs integration for Beignet

    Caution

    Beignet is experimental alpha software. The 0.0.x package line is for early evaluation, and APIs may change between releases while the framework settles.

    This package gives you a thin bridge between contract query params and nuqs URL state.

    It does not replace @beignet/react-query. Instead, it helps you keep URL-backed filters aligned with a contract's query shape and then pass that state into rq(contract).queryOptions(...).

    npm install @beignet/nuqs @beignet/core @beignet/react-query nuqs react @tanstack/react-query
    

    In Next.js App Router, mount the NuqsAdapter once near the root:

    import { NuqsAdapter } from "@beignet/nuqs/next/app";

    export function Providers({ children }: { children: React.ReactNode }) {
    return <NuqsAdapter>{children}</NuqsAdapter>;
    }
    import { createClient } from "@beignet/core/client";
    import { createReactQuery } from "@beignet/react-query";
    import { createNuqs } from "@beignet/nuqs";

    const client = createClient({ baseUrl: "/api" });

    export const rq = createReactQuery(client);
    export const nq = createNuqs();
    import { parseAsInteger, parseAsString } from "nuqs";
    import { useQuery } from "@tanstack/react-query";
    import { nq, rq } from "@/client";
    import { listContacts } from "@/features/contacts/contracts";

    const contactsSearch = nq(listContacts).query({
    parsers: {
    search: parseAsString.withDefault(""),
    offset: parseAsInteger.withDefault(0),
    },
    });

    function ContactsPage() {
    const [filters, setFilters] = contactsSearch.useState();

    const query = useQuery(
    contactsSearch.toQueryOptions(rq(listContacts), filters)
    );

    return null;
    }

    Creates the Beignet nuqs adapter factory.

    Creates a contract-aware URL query helper.

    • parsers: required nuqs parser map keyed by the contract's query params
    • history, shallow, scroll, urlKeys, etc.: forwarded to useQueryStates

    Wraps nuqs useQueryStates(parsers, options) with the configured parser map.

    Converts nuqs state into a Beignet query object.

    • omitNullish defaults to true
    • null and undefined are removed
    • valid falsy values like 0, false, and "" are preserved
    • Date state is serialized as ISO-8601 and parseAsJson object state is serialized as JSON by the Beignet client used by toQueryOptions(...)

    Convenience helper that calls rq(contract).queryOptions({ query, ...options }).

    @beignet/nuqs is a good fit for pages where the URL should reflect search or filter state:

    • admin tables
    • search screens
    • dashboards
    • reporting pages
    • index/list views with tabs, pagination, or filters

    If you just need typed fetching, use @beignet/react-query directly.

    next/app