Skip to content

feat: add signUp support to client, React, React Router and Next.js#184

Merged
halvaradop merged 7 commits into
masterfrom
feat/add-sign-up-in-client
Jun 10, 2026
Merged

feat: add signUp support to client, React, React Router and Next.js#184
halvaradop merged 7 commits into
masterfrom
feat/add-sign-up-in-client

Conversation

@halvaradop

@halvaradop halvaradop commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

This pull request introduces the signUp client function through createAuthClient, enabling sign-up operations from client-side applications.

The new signUp function interacts with the POST /signUp endpoint 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 useSignUp hook to the React, React Router, and Next.js packages. The hook exposes the signUp function along with an isPending state, allowing applications to easily manage the sign-up lifecycle and loading states.

Features

  • Client-side signUp function via createAuthClient
  • Integration with the POST /signUp endpoint
  • useSignUp hook for React
  • useSignUp hook for React Router
  • useSignUp hook for Next.js
  • Built-in loading state management through isPending

Usage

const authClient = createAuthClient({
  baseURL: "http://localhost:3000",
})

const output = await authClient.signUp({
  payload: {
    name: "John",
    lastName: "Doe",
    email: "johndoe@example.com",
    password: "1234567890",
  },
})

Hook Usage

const { signUp, isPending } = useSignUp()

await signUp({
  payload: {
    name: "John",
    lastName: "Doe",
    email: "johndoe@example.com",
    password: "1234567890",
  },
})

@coderabbitai pause

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth Ready Ready Preview, Comment Jun 10, 2026 7:43pm

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@halvaradop, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea67fbc8-8b8b-4141-b67a-25c3bef23e10

📥 Commits

Reviewing files that changed from the base of the PR and between 81c24e8 and 91a380b.

📒 Files selected for processing (2)
  • .github/workflows/ci.yaml
  • packages/react/src/index.tsx
📝 Walkthrough

Walkthrough

Adds 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.

Changes

Core and React SignUp Feature

Layer / File(s) Summary
Core SignUp Types and Contracts
packages/core/src/@types/api.ts, packages/core/src/client/client.ts, packages/core/CHANGELOG.md
Adds SignUpOptions and SignUpReturn, extends createAuthClient generics for sign-up payload typing, and documents signUp in core changelog.
Core Client SignUp Implementation and Documentation
packages/core/src/client/client.ts
Implements client.signUp calling POST /signUp, handles JSON redirectURL, optional browser redirect, consistent error return shape, and adds JSDoc for related auth methods; exposes signUp on the returned client object.
Core Client SignUp Tests
packages/core/test/client/client.test.ts
Adds tests verifying request body/searchParams, error-path return shape, and redirect behavior via window.location.assign stubs.
React useSignUp Hook Implementation and Exports
packages/react/src/hooks.ts, packages/react/src/index.tsx, packages/react/CHANGELOG.md, packages/react/test/hooks/presets.tsx
Adds useSignUp hook that calls client.signUp with redirect:false, provides isPending, optionally performs redirects, broadcasts session:sync on success, and re-exports the hook from the React package; mock client updated for tests.
React useSignUp Hook Tests
packages/react/test/hooks/useSignUp.test.tsx
Comprehensive tests covering usage outside provider, redirect cases (default/explicit/fallback), async isPending behavior, BroadcastChannel messaging, and UI integration (button disabled/label while pending).
Framework Integrations and Exports
packages/next/src/client.ts, packages/next/CHANGELOG.md, packages/react-router/src/client.tsx, packages/react-router/CHANGELOG.md, packages/react/CHANGELOG.md
Re-exports useSignUp in Next.js and React Router packages and updates framework changelogs to document the new hook and its returned fields.
Trailing JSON Normalization
packages/*/package.json
Whitespace/EOF normalization of several package.json files (no metadata changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • aura-stack-ts/auth#183: Introduces the core signUp API endpoint and server-side types that the client.signUp consumes.
  • aura-stack-ts/auth#172: Adds BroadcastChannel-based session sync used by useSignUp to post session:sync.
  • aura-stack-ts/auth#142: Adds the react-router client entrypoint that re-exports auth hooks; this PR re-exports useSignUp there.

Suggested labels

feature, enhancement

Poem

🐰 A signup hops in, typed and bright,
From core to hooks, it leaps in flight.
Redirects set and states kept true,
Broadcasts chirp — the tabs all knew.
Cute tests, docs, and exports too.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding signUp support across multiple packages (client, React, React Router, and Next.js).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-sign-up-in-client

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/react/src/hooks.ts (1)

203-203: ⚡ Quick win

Remove unnecessary non-null assertion.

The non-null assertion operator (!) on value.redirectURL! is unnecessary because performRedirect (line 47) already handles null/undefined values gracefully by checking if (!url) return. For consistency with useSignInCredentials (line 153), which passes value.redirectURL without 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0bb2d5f and 3a7545a.

📒 Files selected for processing (13)
  • packages/core/CHANGELOG.md
  • packages/core/src/@types/api.ts
  • packages/core/src/client/client.ts
  • packages/core/test/client/client.test.ts
  • packages/next/CHANGELOG.md
  • packages/next/src/client.ts
  • packages/react-router/CHANGELOG.md
  • packages/react-router/src/client.tsx
  • packages/react/CHANGELOG.md
  • packages/react/src/hooks.ts
  • packages/react/src/index.tsx
  • packages/react/test/hooks/presets.tsx
  • packages/react/test/hooks/useSignUp.test.tsx

Comment thread packages/core/test/client/client.test.ts Outdated
Comment thread packages/react-router/src/client.tsx
Comment thread packages/react/src/hooks.ts Outdated
Comment thread packages/react/test/hooks/useSignUp.test.tsx
@halvaradop halvaradop merged commit e972b57 into master Jun 10, 2026
7 checks passed
@halvaradop halvaradop deleted the feat/add-sign-up-in-client branch June 10, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant