waitkit
v0.4.0
Published
WaitKit SDK — waitlist infrastructure for your app
Downloads
821
Maintainers
Readme
waitkit
WaitKit SDK — waitlist infrastructure for your app.
Install
npm install waitkitUsage
import { WaitKit } from "waitkit";
const wk = new WaitKit({
apiKey: "wk_...",
projectSlug: "my-project",
});
// Add a subscriber (source defaults to "landing-page")
await wk.subscribers.create({ email: "[email protected]" });
// Override source per-signup
await wk.subscribers.create({ email: "[email protected]", source: "referral" });
// Get subscriber count
const count = await wk.subscribers.count();React
import { WaitKit } from "waitkit";
import { useWaitlist } from "waitkit/react";
const wk = new WaitKit({ apiKey: "wk_...", projectSlug: "my-project" });
function WaitlistForm() {
const { join, count, isJoining, error } = useWaitlist(wk);
return (
<form onSubmit={() => join({ email: "[email protected]" })}>
<p>Joined: {count}</p>
<button disabled={isJoining} type="submit">
Join
</button>
{error && <p>{error.message}</p>}
</form>
);
}API
WaitKitConfig
| Param | Type | Default | Description |
| ------------- | -------- | --------------------- | ------------------------------ |
| apiKey | string | — | API key |
| projectSlug | string | — | Project slug |
| baseUrl | string | https://waitkit.dev | API base URL |
| source | string | landing-page | Default source for all signups |
wk.subscribers.create(options)
| Param | Type | Required | Description |
| ---------- | ------------------------- | -------- | -------------------------------------------- |
| email | string | yes | Subscriber email |
| name | string | no | Subscriber name |
| source | string | no | Overrides the default source for this signup |
| metadata | Record<string, unknown> | no | Arbitrary metadata |
The source value is resolved with this precedence:
create({ source })— per-call overridenew WaitKit({ source })— instance default"landing-page"— built-in fallback
wk.subscribers.count(projectSlug?)
Returns total subscriber count. Optionally pass a different project slug.
License
ISC
