React hooks for querying and mutating agent widgets via TanStack Query and toast notifications.
// Source: https://github.com/allgpt-co/QuickVoice | License: MIT | Copyright 2026 QuickVoice contributors
// Provided via justclaw.it.com; keep this notice with the code.
"use client";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner";
import { queryKeys } from "@/src/lib/query-keys";
import {
widgetsApi,
type CreateAgentWidgetInput,
type UpdateAgentWidgetInput,
} from "@/src/lib/api/resources/widgets";
export function useAgentWidgets(agentId: string) {
return useQuery({
queryKey: queryKeys.agents.widgets(agentId),
queryFn: () => widgetsApi.listForAgent(agentId),
enabled: !!agentId,
});
}
export function useCreateAgentWidget(agentId: string) {
const qc = useQueryClient();
return useMutation({
mut
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key