JavaScript SDK
Subscribers
Create subscribers and retrieve waitlist counts using the SDK.
The subscribers resource handles waitlist signups and counts.
create
Adds a subscriber to the waitlist.
Call this method from the browser only. Server-side calls will record your deployment server's IP and location instead of the actual subscriber. See Integration Guide for framework-specific setup.
const result = await wk.subscribers.create({
email: "user@example.com",
});Parameters
| Param | Type | Required | Description |
|---|---|---|---|
email | string | yes | Subscriber email address |
name | string | no | Subscriber display name |
source | string | no | Overrides the default source for this signup |
metadata | Record<string, unknown> | no | Arbitrary metadata (JSON-serializable) |
Source precedence
The source value is resolved in this order:
create({ source })— per-call overridenew WaitKit({ source })— instance default"landing-page"— built-in fallback
// Uses instance default ("referral")
const wk = new WaitKit({
apiKey: "...",
projectSlug: "...",
source: "referral",
});
// Override per-call ("partner-page")
await wk.subscribers.create({ email: "a@example.com", source: "partner-page" });
// Uses instance default ("referral")
await wk.subscribers.create({ email: "b@example.com" });
// No instance default specified — falls back to "landing-page"
const wk2 = new WaitKit({ apiKey: "...", projectSlug: "..." });
await wk2.subscribers.create({ email: "c@example.com" });Response
Returns the created subscriber entry with its generated ID and timestamps.
interface JoinResult {
id: string;
email: string;
name?: string;
source?: string;
createdAt: string;
}count
Returns the total number of subscribers for the project.
const count = await wk.subscribers.count();
// => 42Optionally pass a different project slug to query another project's count:
const count = await wk.subscribers.count("other-project");Errors
Both methods throw WaitKitError on failure. See the Error Handling guide for details.
