Skip to Content
ReferenceJavaScript SDK

JavaScript SDK

w.js is a 3 KB script with no UI. It remembers ?ref= and UTM tags for 30 days and sends them with the signup.

<script src="https://waitlistly.live/w.js" data-key="pk_your_public_key" async></script>

Waitlistly.join(data)

const contact = await Waitlistly.join({ email: 'ada@example.com', name: 'Ada', // optional answer: 'Founder', // optional fields: { role: 'Founder' }, // optional }); // → same response as POST /v1/contacts

Rejects with an Error whose message is safe to show, plus status and code.

Waitlistly.position(referralCode)

const { position, total, referrals } = await Waitlistly.position('k3x9p2aa');

Waitlistly.invite(code?)

Reads ?invite_code= from the invite link (or takes a code) and returns the invited email while the invite is usable.

const invite = await Waitlistly.invite(); // → { valid: true, code: 'K7QM-2XPD', email: 'ada@example.com', expires_at: '…' } or null without a code

Prefill your sign-up form

Add data-waitlistly-invite to your sign-up form. On pages opened from an invite link, the SDK fills [name=email] and [name=invite_code], sets data-waitlistly-invite-state="valid | invalid", and fires waitlistly:invite. It works with React and Vue inputs.

<form data-waitlistly-invite action="/signup" method="post"> <input name="email" type="email" required /> <input name="invite_code" type="hidden" /> <input name="password" type="password" required /> <button type="submit">Create account</button> </form>

Call Waitlistly.prefill(form) to run it yourself. The code is kept for the browser session, so it survives a redirect inside your sign-up flow.

Your own form, no JavaScript to write

Add data-waitlistly to a form with an email input. The SDK submits it and fires events. It never changes your markup.

<form data-waitlistly> <input name="email" type="email" required /> <button type="submit">Join</button> </form> <script> document.addEventListener('waitlistly:joined', (e) => console.log(e.detail.position)); document.addEventListener('waitlistly:error', (e) => console.log(e.detail.message)); </script>

The form gets data-waitlistly-state="submitting | joined | error" for styling.

Last updated on