-
Notifications
You must be signed in to change notification settings - Fork 424
feat(react): Implement waitlist hook with signal primitives #7097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brkalow
merged 27 commits into
main
from
cursor/implement-waitlist-hook-with-signal-primitives-3ad1
Jan 8, 2026
Merged
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
26419cb
feat: Add waitlist resource and hooks
cursoragent bd48cfc
feat: Add waitlist page and functionality
cursoragent 7dc031e
Refactor: Remove waitlist from client and move to state
cursoragent 000592b
Refactor: Inline JoinWaitlistParams type
cursoragent c3484e1
remove experimental exports
brkalow 1e6865f
updates type
brkalow 12688ca
fix types
brkalow 60ca143
move JoinWaitlistParams
brkalow bfc3364
fix implementation, get tests passing
brkalow 4b79f9a
snapdates
brkalow 8af2285
Merge branch 'vincent-and-the-doctor' into cursor/implement-waitlist-…
brkalow 61b8bd0
merges with base and other updates
brkalow 17774f2
Address PR feedback
brkalow 346a83d
revert unnecessary changes
brkalow d541b79
Remove WaitlistFuture
brkalow 203131c
Fixes waitlist test cleanup and proper property access on waitlist re…
brkalow 8a6e71f
Merge branch 'vincent-and-the-doctor' into cursor/implement-waitlist-…
brkalow cd0104b
Merge branch 'vincent-and-the-doctor' into cursor/implement-waitlist-…
brkalow 406f16a
Merge branch 'main' into cursor/implement-waitlist-hook-with-signal-p…
brkalow 3386df5
Merge branch 'main' into cursor/implement-waitlist-hook-with-signal-p…
brkalow b24759b
fix(clerk-js): Update _waitlistInstance on resource update
brkalow 51f6853
fix(integration): Use unique emails per waitlist test
brkalow f8606fa
Merge branch 'main' into cursor/implement-waitlist-hook-with-signal-p…
brkalow ce964e5
format
brkalow 0cf9faf
adds changeset
brkalow 2da25c6
Merge branch 'main' into cursor/implement-waitlist-hook-with-signal-p…
brkalow c7b5ae7
address PR feedback
brkalow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
integration/templates/custom-flows-react-vite/src/routes/Waitlist.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| 'use client'; | ||
|
|
||
| import { cn } from '@/lib/utils'; | ||
| import { Button } from '@/components/ui/button'; | ||
| import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; | ||
| import { Input } from '@/components/ui/input'; | ||
| import { Label } from '@/components/ui/label'; | ||
| import { useWaitlist } from '@clerk/react'; | ||
| import { NavLink } from 'react-router'; | ||
|
|
||
| export function Waitlist({ className, ...props }: React.ComponentProps<'div'>) { | ||
| const { waitlist, errors, fetchStatus } = useWaitlist(); | ||
|
|
||
| const handleSubmit = async (formData: FormData) => { | ||
| const emailAddress = formData.get('emailAddress') as string | null; | ||
|
|
||
| if (!emailAddress) { | ||
| return; | ||
| } | ||
|
|
||
| await waitlist.join({ emailAddress }); | ||
| }; | ||
|
|
||
| if (waitlist?.id) { | ||
| return ( | ||
| <div | ||
| className={cn('flex flex-col gap-6', className)} | ||
| {...props} | ||
| > | ||
| <Card> | ||
| <CardHeader className='text-center'> | ||
| <CardTitle className='text-xl'>Successfully joined!</CardTitle> | ||
| <CardDescription>You're on the waitlist</CardDescription> | ||
| </CardHeader> | ||
| <CardContent> | ||
| <div className='grid gap-6'> | ||
| <div className='text-center text-sm'> | ||
| Already have an account?{' '} | ||
| <NavLink | ||
| to='/sign-in' | ||
| className='underline underline-offset-4' | ||
| data-testid='sign-in-link' | ||
| > | ||
| Sign in | ||
| </NavLink> | ||
| </div> | ||
| </div> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn('flex flex-col gap-6', className)} | ||
| {...props} | ||
| > | ||
| <Card> | ||
| <CardHeader className='text-center'> | ||
| <CardTitle className='text-xl'>Join the Waitlist</CardTitle> | ||
| <CardDescription>Enter your email address to join the waitlist</CardDescription> | ||
| </CardHeader> | ||
| <CardContent> | ||
| <form action={handleSubmit}> | ||
| <div className='grid gap-6'> | ||
| <div className='grid gap-6'> | ||
| <div className='grid gap-3'> | ||
| <Label htmlFor='emailAddress'>Email address</Label> | ||
| <Input | ||
| id='emailAddress' | ||
| type='email' | ||
| placeholder='Email address' | ||
| required | ||
| name='emailAddress' | ||
| data-testid='email-input' | ||
| /> | ||
| {errors.fields.emailAddress && ( | ||
| <p | ||
| className='text-sm text-red-600' | ||
| data-testid='email-error' | ||
| > | ||
| {errors.fields.emailAddress.longMessage} | ||
| </p> | ||
| )} | ||
| </div> | ||
| <Button | ||
| type='submit' | ||
| className='w-full' | ||
| disabled={fetchStatus === 'fetching'} | ||
| data-testid='submit-button' | ||
| > | ||
| Join Waitlist | ||
| </Button> | ||
| </div> | ||
| <div className='text-center text-sm'> | ||
| Already have an account?{' '} | ||
| <NavLink | ||
| to='/sign-in' | ||
| className='underline underline-offset-4' | ||
| data-testid='sign-in-link' | ||
| > | ||
| Sign in | ||
| </NavLink> | ||
| </div> | ||
| </div> | ||
| </form> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import { parsePublishableKey } from '@clerk/shared/keys'; | ||
| import { clerkSetup } from '@clerk/testing/playwright'; | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| import type { Application } from '../../models/application'; | ||
| import { appConfigs } from '../../presets'; | ||
| import type { FakeUser } from '../../testUtils'; | ||
| import { createTestUtils } from '../../testUtils'; | ||
|
|
||
| test.describe('Custom Flows Waitlist @custom', () => { | ||
| test.describe.configure({ mode: 'parallel' }); | ||
| let app: Application; | ||
| let fakeUser: FakeUser; | ||
|
|
||
| test.beforeAll(async () => { | ||
| app = await appConfigs.customFlows.reactVite.clone().commit(); | ||
| await app.setup(); | ||
| await app.withEnv(appConfigs.envs.withWaitlistdMode); | ||
| await app.dev(); | ||
|
|
||
| const publishableKey = appConfigs.envs.withWaitlistdMode.publicVariables.get('CLERK_PUBLISHABLE_KEY'); | ||
| const secretKey = appConfigs.envs.withWaitlistdMode.privateVariables.get('CLERK_SECRET_KEY'); | ||
| const apiUrl = appConfigs.envs.withWaitlistdMode.privateVariables.get('CLERK_API_URL'); | ||
| const { frontendApi: frontendApiUrl } = parsePublishableKey(publishableKey); | ||
|
|
||
| await clerkSetup({ | ||
| publishableKey, | ||
| frontendApiUrl, | ||
| secretKey, | ||
| // @ts-expect-error | ||
| apiUrl, | ||
| dotenv: false, | ||
| }); | ||
|
|
||
| const u = createTestUtils({ app }); | ||
| fakeUser = u.services.users.createFakeUser({ | ||
| fictionalEmail: true, | ||
| }); | ||
| }); | ||
|
|
||
| test.afterAll(async () => { | ||
| await fakeUser.deleteIfExists(); | ||
| await app.teardown(); | ||
| }); | ||
|
|
||
| test('can join waitlist with email', async ({ page, context }) => { | ||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/waitlist'); | ||
| await u.page.waitForClerkJsLoaded(); | ||
| await expect(u.page.getByText('Join the Waitlist', { exact: true })).toBeVisible(); | ||
|
|
||
| const emailInput = u.page.getByTestId('email-input'); | ||
| const submitButton = u.page.getByTestId('submit-button'); | ||
|
|
||
| await emailInput.fill(fakeUser.email); | ||
| await submitButton.click(); | ||
|
|
||
| await expect(u.page.getByText('Successfully joined!')).toBeVisible(); | ||
| await expect(u.page.getByText("You're on the waitlist")).toBeVisible(); | ||
| }); | ||
|
|
||
| test('renders error with invalid email', async ({ page, context }) => { | ||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/waitlist'); | ||
| await u.page.waitForClerkJsLoaded(); | ||
| await expect(u.page.getByText('Join the Waitlist', { exact: true })).toBeVisible(); | ||
|
|
||
| const emailInput = u.page.getByTestId('email-input'); | ||
| const submitButton = u.page.getByTestId('submit-button'); | ||
|
|
||
| await emailInput.fill('invalid-email@com'); | ||
| await submitButton.click(); | ||
|
|
||
| await expect(u.page.getByTestId('email-error')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('displays loading state while joining', async ({ page, context }) => { | ||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/waitlist'); | ||
| await u.page.waitForClerkJsLoaded(); | ||
| await expect(u.page.getByText('Join the Waitlist', { exact: true })).toBeVisible(); | ||
|
|
||
| const emailInput = u.page.getByTestId('email-input'); | ||
| const submitButton = u.page.getByTestId('submit-button'); | ||
|
|
||
| await emailInput.fill(fakeUser.email); | ||
|
|
||
| const submitPromise = submitButton.click(); | ||
|
|
||
| // Check that button is disabled during fetch | ||
| await expect(submitButton).toBeDisabled(); | ||
|
|
||
| await submitPromise; | ||
|
|
||
| // Wait for success state | ||
| await expect(u.page.getByText('Successfully joined!')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('can navigate to sign-in from waitlist', async ({ page, context }) => { | ||
brkalow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/waitlist'); | ||
| await u.page.waitForClerkJsLoaded(); | ||
| await expect(u.page.getByText('Join the Waitlist', { exact: true })).toBeVisible(); | ||
|
|
||
| const signInLink = u.page.getByTestId('sign-in-link'); | ||
| await expect(signInLink).toBeVisible(); | ||
| await signInLink.click(); | ||
|
|
||
| await expect(u.page.getByText('Sign in', { exact: true })).toBeVisible(); | ||
| await u.page.waitForURL(/sign-in/); | ||
| }); | ||
|
|
||
| test('waitlist hook provides correct properties', async ({ page, context }) => { | ||
brkalow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/waitlist'); | ||
| await u.page.waitForClerkJsLoaded(); | ||
|
|
||
| // Check initial state - waitlist resource should be available but empty | ||
| const emailInput = u.page.getByTestId('email-input'); | ||
| const submitButton = u.page.getByTestId('submit-button'); | ||
|
|
||
| await expect(emailInput).toBeVisible(); | ||
| await expect(submitButton).toBeEnabled(); | ||
|
|
||
| // Join waitlist | ||
| await emailInput.fill(fakeUser.email); | ||
| await submitButton.click(); | ||
|
|
||
| // After successful join, the component should show success state | ||
| await expect(u.page.getByText('Successfully joined!')).toBeVisible(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destructuring from potentially
nullreturn value will cause runtime TypeErrorparsePublishableKeycan returnnull(see its signature in@clerk/shared/keys). Destructuring directly without a null check will throw at runtime if the key is invalid or missing.Use
{ fatal: true }to throw a descriptive error, or add a null guard:🤖 Prompt for AI Agents