Skip to content

Conversation

@Ayush2k02
Copy link

@Ayush2k02 Ayush2k02 commented Dec 26, 2025

Summary

Fixes redirect conflicts when SignIn and SignUp components are used together on the same page.

Problem

When both <SignIn /> and <SignUp /> components are rendered on the same page (e.g., as tabs in a modal), they interfere with each other's navigation flows. Specifically:

  1. User loads a page with both SignIn and SignUp components
  2. User attempts to sign in with an email code
  3. The sign-in flow navigates to /factor-one
  4. The SignUp component's catch-all route matches and triggers RedirectToSignUp()
  5. User is unexpectedly redirected to the Clerk domain, losing context

Root Cause

The RedirectToSignIn and RedirectToSignUp components in both SignIn/index.tsx:40-46 and SignUp/index.tsx:21-27 had incomplete dependency arrays:

function RedirectToSignUp() {
  const clerk = useClerk();
  React.useEffect(() => {
    void clerk.redirectToSignUp();
  }, []); // ❌ Missing 'clerk' dependency
  return null;
}

React's exhaustive-deps rule requires including all dependencies used inside useEffect. Without clerk in the dependency array, the effect doesn't properly track when it should run, leading to unexpected behavior when multiple components share the same router context.

Solution

Added clerk to the dependency arrays in both redirect components:

function RedirectToSignUp() {
  const clerk = useClerk();
  React.useEffect(() => {
    void clerk.redirectToSignUp();
  }, [clerk]); // ✅ Properly tracks clerk instance
  return null;
}

This ensures the redirect only happens when the clerk instance changes, preventing unwanted redirects during navigation in other component flows.

Changes

Testing

This fix allows:

  • ✅ Inline SignIn and SignUp forms to coexist on the same page
  • ✅ Multi-step authentication flows to work without cross-component interference
  • ✅ Email code sign-in to complete without unexpected redirects

Notes

⚠️ Draft PR - This needs testing with the reproduction case to verify it fully resolves the issue.

Related to issue #7456

Fixes token-type-mismatch error when using arrays in acceptsToken option.
Previously, when acceptsToken was an array like ['session_token', 'api_key'],
the code would always route to the machine token handler, causing session
tokens to fail with token-type-mismatch errors.

Now, when acceptsToken is an array, the function checks the actual token
type and routes to the appropriate handler (session or machine).

- Added routing logic for array acceptsToken values
- Added tests for mixed token type arrays
- Preserves backward compatibility with existing usage

Fixes clerk#7520
Fixes an issue where SignUp and SignIn components interfere with each
other when both are rendered on the same page. Previously, the catch-all
redirect routes would trigger on every render due to missing dependency
arrays in their useEffect hooks.

The RedirectToSignIn and RedirectToSignUp components had useEffect hooks
with empty dependency arrays [], but React best practices require
including all dependencies. Adding 'clerk' to the dependency array
ensures the redirect only happens when the clerk instance changes,
preventing unwanted redirects during navigation in other flows.

This fix allows inline SignIn and SignUp forms to coexist on the same
page without interfering with each other's multi-step authentication flows.

Fixes clerk#7456
@changeset-bot
Copy link

changeset-bot bot commented Dec 26, 2025

🦋 Changeset detected

Latest commit: 5259358

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@clerk/backend Patch
@clerk/ui Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/chrome-extension Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 26, 2025

@Ayush2k02 is attempting to deploy a commit to the Clerk Production Team on Vercel.

A member of the Team first needs to authorize it.

@Ayush2k02 Ayush2k02 closed this Dec 26, 2025
@Ayush2k02 Ayush2k02 deleted the fix/signup-signin-redirect-conflict branch December 26, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant