feat: add signUp support to client, React, React Router and Next.js#184
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 48 minutes and 55 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a client-side signUp method and types, implements signUp in createAuthClient with JSDoc, adds core tests, exposes a React useSignUp hook (with async state, redirect handling, and broadcast sync), wires hook exports into framework packages, and normalizes trailing package.json whitespace. ChangesCore and React SignUp Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
packages/react/src/hooks.ts (1)
203-203: ⚡ Quick winRemove unnecessary non-null assertion.
The non-null assertion operator (
!) onvalue.redirectURL!is unnecessary becauseperformRedirect(line 47) already handles null/undefined values gracefully by checkingif (!url) return. For consistency withuseSignInCredentials(line 153), which passesvalue.redirectURLwithout the assertion, remove the!operator.♻️ Proposed fix
if (options?.redirect === true) { - await performRedirect(redirect, value.redirectURL!) + await performRedirect(redirect, value.redirectURL) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react/src/hooks.ts` at line 203, Remove the unnecessary non-null assertion when passing value.redirectURL to performRedirect: in packages/react/src/hooks.ts locate the call to performRedirect(redirect, value.redirectURL!) and change it to pass value.redirectURL without the trailing "!" so it becomes performRedirect(redirect, value.redirectURL). performRedirect already guards against null/undefined (if (!url) return), and this aligns with how useSignInCredentials passes value.redirectURL elsewhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/test/client/client.test.ts`:
- Around line 428-455: The test calls client.signUp(...) without awaiting the
returned Promise, so the assertion on the mocked post may run before the async
call completes; update the test to be asynchronous (make the test function
async) and await client.signUp(...) after creating the client from
createAuthClient and before the expect(post).toHaveBeenCalledWith(...) assertion
to ensure the mock post has been invoked (reference client.signUp,
createAuthClient, and the post mock).
In `@packages/react-router/src/client.tsx`:
- Line 9: The type declarations for `@aura-stack/react` are missing useSignUp, so
update the package declaration output and build references: ensure
packages/react exports include useSignUp by verifying the export in
packages/react/src/index.tsx is compiled into the declaration bundle (generate
an index.d.ts that re-exports useSignUp from hooks), and update
packages/react/package.json "types" and "exports" mapping to point to that
declaration file; additionally ensure packages/react-router consumes the fresh
declarations by either adding a TS project reference to the react package in its
tsconfig (so the declaration is produced and used) or by ensuring the built
packages/react/dist (or build) contains the index.d.ts with useSignUp before
react-router builds.
In `@packages/react/src/hooks.ts`:
- Line 196: The signUp callback in useSignUp is missing an explicit return type;
update its signature to return Promise<SignUpReturn<Options>> (where Options
extends SignUpOptions<Payload>) and import SignUpReturn from
"`@aura-stack/auth/types`" so the callback matches other hooks (e.g.,
useSignInCredentials) and uses the existing SignUpReturn type; locate the signUp
callback in useSignUp and add the return annotation and the import.
In `@packages/react/test/hooks/useSignUp.test.tsx`:
- Line 170: The pending UI test in packages/react/test/hooks/useSignUp.test.tsx
currently only asserts the pending label and uses getByRole(...).toBeDefined(),
which is redundant; update the test to explicitly assert the submit button is
disabled by grabbing the button with getByRole('button', { name: /submit/i })
(or the existing getByRole call) and adding expect(submitButton).toBeDisabled()
(or expect(submitButton.disabled).toBe(true)); remove the unnecessary
toBeDefined() call. Apply the same change to the other pending-test occurrence
around the later assertion mentioned.
---
Nitpick comments:
In `@packages/react/src/hooks.ts`:
- Line 203: Remove the unnecessary non-null assertion when passing
value.redirectURL to performRedirect: in packages/react/src/hooks.ts locate the
call to performRedirect(redirect, value.redirectURL!) and change it to pass
value.redirectURL without the trailing "!" so it becomes
performRedirect(redirect, value.redirectURL). performRedirect already guards
against null/undefined (if (!url) return), and this aligns with how
useSignInCredentials passes value.redirectURL elsewhere.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 859977ae-9406-4a6b-8545-e17068c5bf46
📒 Files selected for processing (13)
packages/core/CHANGELOG.mdpackages/core/src/@types/api.tspackages/core/src/client/client.tspackages/core/test/client/client.test.tspackages/next/CHANGELOG.mdpackages/next/src/client.tspackages/react-router/CHANGELOG.mdpackages/react-router/src/client.tsxpackages/react/CHANGELOG.mdpackages/react/src/hooks.tspackages/react/src/index.tsxpackages/react/test/hooks/presets.tsxpackages/react/test/hooks/useSignUp.test.tsx
Description
This pull request introduces the
signUpclient function throughcreateAuthClient, enabling sign-up operations from client-side applications.The new
signUpfunction interacts with thePOST /signUpendpoint introduced in the previous sign-up flow implementation, providing a type-safe API for creating user accounts directly from the client.Additionally, this PR adds the
useSignUphook to the React, React Router, and Next.js packages. The hook exposes thesignUpfunction along with anisPendingstate, allowing applications to easily manage the sign-up lifecycle and loading states.Features
signUpfunction viacreateAuthClientPOST /signUpendpointuseSignUphook for ReactuseSignUphook for React RouteruseSignUphook for Next.jsisPendingUsage
Hook Usage
@coderabbitai pause