Custom Hooks
Easy state management and API integration of waitlist features in your frontend.
useWaitlist()
We create a single hook to implement waitlist functionality on the client. This allows us to have multiple entry points for the waitlist without duplicating logic.
If you prefer to avoid additional abstraction, you can move this logic to the waitlist component.
Property | Usage |
---|---|
email | Bind to input value to control the email field. |
emailInputRef | Attach to input element for focus management. |
isSubmitting | Show loading state during form submission. |
isDone | Display success message or redirect after signup. |
error | Show validation or server errors to user. |
signUpInfo | Access referral code and URL after successful signup. |
handleSubmit | Bind to form onSubmit to process registration. |
handleEmailChange | Bind to input onChange to update email value. |
Key Design Decisions
- Maintains form state internally to reduce boilerplate in consuming components.
- Automatically handles referral codes from URL search parameters.
- Provides input ref for programmatic focus management, i.e., after validation error.
- Separates validation errors from server errors for better UX.
- Manages loading, success, and error states automatically.
- Clears error messages on input change for better user feedback.
- Returns minimal interface with typed handlers and state values.