Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/major-parks-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/clerk-js": patch
---

Support both `clerkUICtor` and `clerkUiCtor` option names for backwards compatibility
5 changes: 5 additions & 0 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3248,9 +3248,14 @@ export class Clerk implements ClerkInterface {
};

#initOptions = (options?: ClerkOptions): ClerkOptions => {
// Support both clerkUICtor (correct) and clerkUiCtor (legacy) for backwards compatibility
const clerkUICtor =
options?.clerkUICtor ?? (options as Record<string, unknown> | undefined)?.clerkUiCtor ?? undefined;

return {
...defaultOptions,
...options,
clerkUICtor: clerkUICtor as ClerkOptions['clerkUICtor'],
allowedRedirectOrigins: createAllowedRedirectOrigins(
Comment on lines 3250 to 3259
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add tests for the legacy alias behavior before merge.

This PR changes initialization to accept both clerkUICtor and clerkUiCtor, but no tests were added to lock in that behavior. Please add coverage for both option names.
As per coding guidelines, “If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.”

🤖 Prompt for AI Agents
In `@packages/clerk-js/src/core/clerk.ts` around lines 3250 - 3259, Add unit tests
to cover the backward-compatible alias behavior introduced in the `#initOptions`
function: write tests that instantiate Clerk (or call
Clerk.prototype.#initOptions via a public initialization helper) passing options
with clerkUICtor and separately with the legacy clerkUiCtor and assert that the
resulting configuration uses the same constructor value in clerkUICtor; include
tests for both merging with defaultOptions and for when only the legacy key is
provided to ensure createAllowedRedirectOrigins and other returned properties
are preserved. Ensure tests reference the public initialization path that
exercises `#initOptions` (e.g., new Clerk(...) or init method) and assert equality
of the effective clerkUICtor and other merged fields.

options?.allowedRedirectOrigins,
this.frontendApi,
Expand Down
Loading