Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 1.99 KB

File metadata and controls

82 lines (56 loc) · 1.99 KB
title `WaitlistFuture`
description The current active `Waitlist` instance, for use in custom flows.
sdk js-frontend

The WaitlistFuture class provides methods and properties to manage waitlist entries in your application. It is used when you want to build a custom waitlist UI instead of using the prebuilt <Waitlist /> component.

Properties

- `id` - `string | undefined`

The unique identifier for the waitlist entry. undefined if the user has not joined the waitlist yet.


  • createdAt
  • Date | null

The date and time the waitlist entry was created. null if the user has not joined the waitlist yet.


  • updatedAt
  • Date | null

The date and time the waitlist entry was last updated. null if the user has not joined the waitlist yet.

Methods

join()

Submits an email address to join the waitlist. This method creates a new waitlist entry for the provided email address.

function join(params: JoinWaitlistParams): Promise<{ error: unknown }>

JoinWaitlistParams

- `emailAddress` - `string`

The email address to add to the waitlist.

Example

'use client'

import { useWaitlist } from '@clerk/react'

export default function WaitlistPage() {
  const { waitlist } = useWaitlist()

  const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault()
    const formData = new FormData(e.currentTarget)
    const emailAddress = formData.get('emailAddress') as string

    const { error } = await waitlist.join({ emailAddress })

    if (error) {
      console.error('Failed to join waitlist:', error)
    }
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="email" name="emailAddress" required />
      <button type="submit">Join Waitlist</button>
    </form>
  )
}