Client Call
GitHubClient-only helper that invokes an asynchronous function after rendering.
Installation
bash
pnpm dlx shadcn@latest add @cs/client-callUsage
tsx
import { ClientCall } from "@/components/cs/client-call";tsx
<ClientCall
data={{ event: "page_view" }}
func={async (data) => {
await fetch("/api/analytics", {
method: "POST",
body: JSON.stringify(data),
});
}}
/>API Reference
ClientCall
Calls an asynchronous function after this client component renders. The component renders no visible output.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| data * | T | - | Data passed to func. |
| func * | (data: T) => Promise<unknown> | - | Asynchronous callback invoked after rendering. |