The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
"use client";
import { clientAccessCheck } from "@/lib/client-access-check";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useWorkspace from "@/lib/swr/use-workspace";
import { Button } from "@dub/ui";
import Link from "next/link";
import { usePathname } from "next/navigation";
export default function CreateWebhookButton() {
const pathname = usePathname();
const { slug, plan, role } = useWorkspace();
const { canCreateWebhooks } = getPlanCapabilities(plan);
const { error: permissionsError } = clientAccessCheck({
action: "webhooks.write",
role: role,
});
// don't show button if not on main webhooks page or if workspace cannot create webhooks
if (!canCreateWebhooks || !pathname.endsWith("/settings/webhooks")) {
return null;
}
return (
<Link href={`/${slug}/settings/webhooks/new`}>
<Button
className="h-9"
text="Create webhook"
disabledTooltip={permissionsError}
aria-label="Create webhook"
/>
</Link>
);
}