Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); fix(js): keep native OAuth transport callbacks inside the component router by wobsoriano · Pull Request #9370 · clerk/javascript · GitHub
Skip to content

fix(js): keep native OAuth transport callbacks inside the component router - #9370

Merged
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation
Aug 10, 2026
Merged

fix(js): keep native OAuth transport callbacks inside the component router#9370
wobsoriano merged 4 commits into
mainfrom
rob/native-oauth-modal-navigation

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes native OAuth transport flows (e.g. @clerk/electron) breaking out of modal components. When a callback needed an intermediate step such as a sign-in to sign-up transfer, the continue step, or an MFA factor, clerk-js navigated the app window to an internal Clerk route like /CLERK-ROUTER/VIRTUAL/sign-up. In Electron apps this reloaded the renderer on a route the app does not have, and the leaked URL was later submitted as the completion redirect, which production instances reject with a "Redirect url mismatch" error (ref).

The prebuilt UI now hands its own router to the transport callback via an internal param so those steps render inside the component, and _authenticateWithTransport now submits the registered transport callback URL as the completion redirect while the app's real destination is navigated client-side. Both changes are internal and optional, so older UI versions keep the existing behavior.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 888ed33

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

This PR includes changesets to release 23 packages
NameType
@clerk/clerk-jsPatch
@clerk/sharedPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/electronPatch
@clerk/expoPatch
@clerk/astroPatch
@clerk/backendPatch
@clerk/expo-passkeysPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/headlessPatch
@clerk/honoPatch
@clerk/localizationsPatch
@clerk/mswPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/reactPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch
@clerk/vuePatch
@clerk/swingsetPatch

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

vercelBot commented Aug 9, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewAug 9, 2026 4:38pm
swingsetReadyReadyPreviewAug 9, 2026 4:38pm

Request Review

@pkg-pr-new

pkg-pr-newBot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9370

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9370

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9370

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9370

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9370

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9370

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9370

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9370

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9370

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9370

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9370

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9370

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9370

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9370

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9370

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9370

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9370

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9370

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9370

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9370

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9370

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9370

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9370

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9370

commit: 888ed33

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
@wobsoriano
wobsoriano marked this pull request as ready for review August 9, 2026 15:30
@github-actions

github-actionsBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-09T16:38:23.498Z

Summary

MetricCount
Packages analyzed19
Packages with changes2
🔴 Breaking changes0
🟡 Non-breaking changes2
🟢 Additions0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.27.1
Recommended bump: MINOR → 4.28.0

Subpath ./types

🟡 Non-breaking Changes (1)

Modified: HandleOAuthCallbackParams
// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
};

Static analyzer: Breaking change in type alias HandleOAuthCallbackParams: Type changed: import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…import("@clerk/shared").SignInFallbackRedirectUrl&import("@clerk/shared").SignInForceRedirectUrl&import("@clerk/shared"…

🤖 AI review (reclassified as non-breaking) (95%): The only change is adding a new optional property __internal_navigate?: (to: string) => Promise<unknown> to HandleOAuthCallbackParams. HandleOAuthCallbackParams is used exclusively in input/parameter positions (as arguments to handleRedirectCallback, handleGoogleOneTapCallback, and as an optional field in AuthenticateWithRedirectParams), so adding an optional property does not break any existing callers — they neither need to supply it nor read it.


@clerk/vue

Current version: 2.4.25
Recommended bump: MINOR → 2.5.0

🟡 Non-breaking Changes (1)

Modified: AuthenticateWithRedirectCallback

// ... 15 unchanged lines elided ...
redirectUrl: string;
decorateUrl: (url: string) => string;
}) => Promise<unknown>;
+ __internal_navigate?: (to: string) => Promise<unknown>;
} & {}, import("vue").PublicProps>

Static analyzer: Breaking change in variable AuthenticateWithRedirectCallback: Type changed: import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…import("@vue/runtime-core").DefineSetupFnComponent<import("@clerk/shared").HandleOAuthCallbackParams,{},{},import("@cle…

🤖 AI review (reclassified as non-breaking) (90%): The only difference between before and after is the addition of a new optional property __internal_navigate?: (to: string) => Promise<unknown> to the props type; adding a new optional property to a component's props (an input type) is non-breaking for existing consumers who do not pass it.


Report generated by Break Check

Last ran on 888ed33.

@coderabbitai

coderabbitaiBot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 822caffc-e7b1-4419-aadd-3a6b377720b9

📥 Commits

Reviewing files that changed from the base of the PR and between 1744c89 and 888ed33.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/core/clerk.ts

📝 Walkthrough

Walkthrough

The change adds internal router navigation to OAuth callback parameters and passes it from sign-in and sign-up social buttons. Clerk JS callback handling uses this navigation before default Clerk navigation. Transport authentication now uses the registered transport URL for both redirect parameters. Tests cover callback routing and redirect replacement. A patch changeset documents the fixes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • clerk/javascript#7928: Both changes modify OAuth redirect callback handling for sign-up continuation navigation.

Suggested reviewers:nikosdouvlis

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the primary fix: keeping native OAuth transport callbacks inside the component router.
Description check✅ PassedThe description accurately explains the router navigation fix, transport redirect change, compatibility, tests, and bug context.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.

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

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts (1)

55-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the new test type-safe.

The new fixture uses as any at Lines 55, 61, and 69. These casts bypass the resource, Clerk, and authentication parameter contracts. Define narrow mock types or construct the required fields so TypeScript can detect API drift in this test.

As per coding guidelines, avoid any types without justification and prefer unknown with type guards when the type is uncertain.

Also applies to: 61-61, 69-69

🤖 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/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts` at
line 55, Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

Source: Coding guidelines

🤖 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.
Nitpick comments:
In `@packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts`:
- Line 55: Remove the `as any` casts from the new fixtures in
`authenticateWithTransport` tests and make the resource, Clerk, and
authentication parameter mocks satisfy their declared contracts. Define narrow
mock types or provide the required fields, using `unknown` with type guards only
where necessary, so TypeScript catches API changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685c0cde-0621-43aa-b705-732bfd37449d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c61153 and 1744c89.

📒 Files selected for processing (10)
  • .changeset/native-oauth-modal-navigation.md
  • packages/clerk-js/src/core/__tests__/clerk.test.ts
  • packages/clerk-js/src/core/clerk.ts
  • packages/clerk-js/src/utils/__tests__/authenticateWithTransport.test.ts
  • packages/clerk-js/src/utils/authenticateWithTransport.ts
  • packages/shared/src/types/clerk.ts
  • packages/ui/src/components/SignIn/SignInSocialButtons.tsx
  • packages/ui/src/components/SignIn/__tests__/SignInSocialButtons.test.tsx
  • packages/ui/src/components/SignUp/SignUpSocialButtons.tsx
  • packages/ui/src/components/SignUp/__tests__/SignUpSocialButtons.test.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go(manual)
  • clerk/dashboard(manual)
  • clerk/accounts(manual)
  • clerk/backoffice(manual)
  • clerk/clerk(manual)
  • clerk/clerk-docs(manual)
  • clerk/cloudflare-workers(manual)
  • clerk/cli(auto-detected)
  • clerk/clerk-ios(auto-detected)
  • clerk/clerk-android(auto-detected)

Comment threadpackages/clerk-js/src/core/clerk.ts Outdated
customNavigate && typeof customNavigate === 'function'
? customNavigate(this.buildUrlWithAuth(to))
resolvedNavigate && typeof resolvedNavigate === 'function'
? resolvedNavigate(this.buildUrlWithAuth(to))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

__internal_navigate should receive the raw component-relative path here. Native transport reaches this method through _authenticateWithTransport__internal_handleResourceCallback; with a development publishable key, buildUrlWithAuth("continue") produces a root-level absolute URL such as http://host/continue. The virtual router then sees /continue as outside /CLERK-ROUTER/VIRTUAL and delegates to window-level navigation, so test-instance Electron flows still break out of the modal. Could we keep the existing decorated behavior for customNavigate, but pass raw to to params.__internal_navigate? A regression test should exercise __internal_handleResourceCallback with developmentPublishableKey; the current test calls handleRedirectCallback with a production key, so it does not cover this path.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

ty for catching!

@jeremy-clerkjeremy-clerk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍 but touches core, would like to see another set of eyes

@wobsoriano
wobsoriano merged commit 131edec into mainAug 10, 2026
52 checks passed
@wobsoriano
wobsoriano deleted the rob/native-oauth-modal-navigation branch August 10, 2026 20:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@wobsoriano@jeremy-clerk