Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
import { toast } from "sonner";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { refreshTrackingKeywordMetrics } from "@/serverFunctions/rank-tracking";
export function useMetricsRefresh(projectId: string, configId: string) {
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: () =>
refreshTrackingKeywordMetrics({
data: { projectId, configId },
}),
onSuccess: (result) => {
void queryClient.invalidateQueries({
queryKey: ["rankTrackingResults", projectId, configId],
});
toast.success(`Metrics updated for ${result.updated} keywords`);
},
});
return { refresh: mutation.mutate, isRefreshing: mutation.isPending };
}