-
Notifications
You must be signed in to change notification settings - Fork 422
feat(ui): Unify ui prop to accept both version object and ClerkUI constructor #7578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…structor This change consolidates the UI module configuration into a single `ui` prop that accepts either: - A version object (`ui` export from @clerk/ui) for hot loading with version pinning - The ClerkUI class constructor (`ClerkUI` export from @clerk/ui) for direct module usage Changes: - Split Ui type into UiVersion and UiModule, with Ui as a union of both - Export ClerkUI constructor from @clerk/ui for direct bundling usage - Update IsomorphicClerk to detect and handle both ui types - Update IsomorphicClerkOptions.ui to accept both types - Keep clerkUiCtor as internal property for clerk.load() compatibility - Update @clerk/astro, @clerk/vue, @clerk/chrome-extension to use new pattern
🦋 Changeset detectedLatest commit: 4cccd8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe PR introduces a unified 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (12)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/src/**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.ts?(x)📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Files:
**/index.ts📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
packages/ui/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/clerk-ui-theming.mdc)
Files:
**/*⚙️ CodeRabbit configuration file
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (6)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/astro/src/internal/create-clerk-instance.ts (1)
123-138: PassclerkUiVersionandclerkUiUrlextracted from theuiobject, matching the React implementation.The
loadClerkUiScriptfunction expectsclerkUiVersionandclerkUiUrlproperties (as defined inLoadClerkUiScriptOptions), but this code passes the entireoptionsobject. Whenuiis an object withversionandurlproperties, those values are ignored because theclerkUiScriptUrlfunction only readsclerkUiUrlandclerkUiVersionproperties—it has no knowledge of theuiobject structure.Extract these values before calling
loadClerkUiScript:const uiVersion = typeof options?.ui === 'object' ? options.ui : undefined; await loadClerkUiScript({ ...options, clerkUiVersion: uiVersion?.version, clerkUiUrl: uiVersion?.url || options?.clerkUiUrl, });
🧹 Nitpick comments (2)
packages/react/src/isomorphicClerk.ts (1)
511-517: Duplicate type guard - consider extracting to@clerk/shared.This
isUiConstructorfunction is duplicated inpackages/astro/src/internal/create-clerk-instance.ts(lines 115-117). To maintain DRY and ensure consistent behavior across packages, consider moving this to@clerk/shared/uialongside theClerkUiConstructortype.packages/astro/src/internal/create-clerk-instance.ts (1)
111-117: Duplicate function - same implementation exists in@clerk/react.This is identical to
isUiConstructorinpackages/react/src/isomorphicClerk.ts. Consider extracting to@clerk/shared/uito avoid divergence.
📜 Review details
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (10)
integration/templates/express-vite/src/client/main.tspackages/astro/src/internal/create-clerk-instance.tspackages/astro/src/types.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/react/src/isomorphicClerk.tspackages/react/src/types.tspackages/shared/src/types/clerk.tspackages/ui/src/index.tspackages/ui/src/internal/index.tspackages/vue/src/plugin.ts
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/astro/src/types.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels
Files:
packages/astro/src/types.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.
Files:
packages/astro/src/types.tsintegration/templates/express-vite/src/client/main.tspackages/react/src/types.tspackages/astro/src/internal/create-clerk-instance.tspackages/shared/src/types/clerk.tspackages/vue/src/plugin.tspackages/react/src/isomorphicClerk.tspackages/ui/src/index.tspackages/chrome-extension/src/react/ClerkProvider.tsxpackages/ui/src/internal/index.ts
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Avoid barrel files (index.ts re-exports) as they can cause circular dependencies
Files:
packages/ui/src/index.tspackages/ui/src/internal/index.ts
packages/ui/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-ui-theming.mdc)
packages/ui/src/**/*.{ts,tsx}: Use element descriptors for all themable elements by applyingelementDescriptorprop to components and importing descriptors frompackages/ui/src/customizables/elementDescriptors.ts
Use theme-aware functions inelementsconfiguration to access design tokens (e.g.,{ theme } => ({ backgroundColor: theme.colors.$primary500 }))
Prefer CSS variables (e.g.,--clerk-color-primary,--clerk-spacing) for runtime customization via theclerkCssVarutility
Automatically generate color scales using the color scale generation process rather than manually defining all lightness and alpha variations (25, 50, 100, 150, 200, 300, 400, 500, 600, 700, 750, 800, 850, 900, 950 shades)
Use thecreateVariantsfunction frompackages/ui/src/styledSystem/createVariants.tsfor type-safe variant-based styling with base, variants, defaultVariants, and compoundVariants configuration
Wrap primitive components withmakeCustomizableHOC frompackages/ui/src/customizables/makeCustomizable.tsxto enable element descriptor support and theming
Apply thesxprop using either a theme-aware function(theme: InternalTheme) => StyleRuleor static style object to components for theme-aware CSS
Use state props (isLoading, hasError, isOpen, isActive) to automatically generate state classes (cl-loading, cl-error, cl-open, cl-active) for styling
Use CSSlight-dark()function via thelightDarkutility frompackages/ui/src/utils/lightDark.tsfor automatic light/dark mode support with fallbacks
Use Emotion'scssprop andThemeProviderviaInternalThemeProviderfrompackages/ui/src/styledSystem/InternalThemeProvider.tsxfor styling and theme context
UsemakeResponsivefrompackages/ui/src/customizables/makeResponsive.tsxwith breakpoints defined inpackages/ui/src/styledSystem/breakpoints.tsxfor responsive design support
UseuseDeepEqualMemoin AppearanceProvider to prevent unnecessary re-renders when appearance configuration changes
Files:
packages/ui/src/index.tspackages/ui/src/internal/index.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components
**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components
Files:
packages/chrome-extension/src/react/ClerkProvider.tsx
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/chrome-extension/src/react/ClerkProvider.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g.,UserProfile,NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...
Files:
packages/chrome-extension/src/react/ClerkProvider.tsx
🧬 Code graph analysis (7)
integration/templates/express-vite/src/client/main.ts (2)
packages/clerk-js/src/core/clerk.ts (2)
publishableKey(300-302)Clerk(211-3120)packages/ui/src/index.ts (1)
ClerkUI(22-22)
packages/astro/src/internal/create-clerk-instance.ts (4)
packages/react/src/isomorphicClerk.ts (2)
isUiConstructor(515-517)getClerkUiEntryChunk(519-543)packages/ui/src/index.ts (1)
ui(13-15)packages/shared/src/ui/types.ts (1)
ClerkUiConstructor(33-41)packages/ui/src/internal/index.ts (1)
Ui(68-68)
packages/shared/src/types/clerk.ts (1)
packages/shared/src/ui/types.ts (1)
ClerkUiConstructor(33-41)
packages/vue/src/plugin.ts (3)
packages/react/src/isomorphicClerk.ts (1)
isUiConstructor(515-517)packages/ui/src/index.ts (1)
ui(13-15)packages/shared/src/ui/types.ts (1)
ClerkUiConstructor(33-41)
packages/react/src/isomorphicClerk.ts (3)
packages/ui/src/index.ts (1)
ui(13-15)packages/shared/src/ui/types.ts (1)
ClerkUiConstructor(33-41)packages/shared/src/loadClerkJsScript.ts (1)
loadClerkUiScript(171-216)
packages/ui/src/index.ts (2)
packages/clerk-js/sandbox/public/mockServiceWorker.js (1)
PACKAGE_VERSION(9-9)packages/ui/src/internal/index.ts (3)
UiVersion(26-37)Appearance(72-72)UiModule(44-61)
packages/chrome-extension/src/react/ClerkProvider.tsx (3)
packages/ui/src/internal/index.ts (2)
UiModule(44-61)Appearance(72-72)packages/react-router/src/client/ReactRouterClerkProvider.tsx (1)
ClerkProvider(126-148)packages/ui/src/index.ts (1)
ClerkUI(22-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (billing, chrome, RQ)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (5)
packages/react/src/isomorphicClerk.ts (1)
519-543: LGTM!The logic correctly handles both UI configuration modes: direct constructor usage short-circuits to return immediately, while version-based configuration proceeds with script loading. The fallback to
this.options.clerkUiUrlpreserves backward compatibility.packages/astro/src/types.ts (1)
39-44: LGTM!The new
uiproperty is well-documented with clear JSDoc explaining both usage modes (version object for hot loading vs. ClerkUI constructor for direct bundling).packages/ui/src/index.ts (1)
17-22: LGTM - double assertion is justified for Tagged types.The
as unknown as UiModule<Appearance>assertion is necessary becauseClerkUiClassdoesn't directly satisfy theTagged<..., 'ClerkUiModule'>branded type structure. The JSDoc clearly documents the purpose of this export.packages/chrome-extension/src/react/ClerkProvider.tsx (2)
12-21: LGTM - appropriate simplification for Chrome extension context.The comment clearly explains why
UiModule<Appearance>is used instead of the genericUitype. Omittinguifrom the exposed props and hardcodingClerkUIinternally is the right approach since Chrome extensions always bundle the UI module.
37-46: LGTM!The
ui={ClerkUI}prop correctly uses the new unifieduiprop pattern instead of the previousclerkUiCtorinternal property.
- Rename `ui` export to `version` in @clerk/ui for clarity - Add `UI_BRAND_SYMBOL` to validate legitimate @clerk/ui exports at runtime - Update detection logic in react, astro, vue to check for brand symbol - Only accept exports with the correct symbol, reject arbitrary objects
- Remove Tagged wrapper from UiVersion and UiModule types since symbol brand already provides sufficient runtime validation - Fix clerk-script.tsx to properly access url property on version objects by checking type at runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/ui/src/internal/index.ts:
- Around line 47-65: The constructor signature on UiModule (new (...args:
any[]): any) uses unconstrained any; change it to a typed constructor by
replacing the args with unknown[] and the instance return with a generic
instance type (e.g., add a second generic like I and use new (...args:
unknown[]): I) so callers retain type safety; update UiModule's definition (and
any call sites) to supply or infer the instance type instead of relying on any
and avoid using any without justification.
📜 Review details
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components
**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components
Files:
packages/nextjs/src/utils/clerk-script.tsx
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/nextjs/src/utils/clerk-script.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g.,UserProfile,NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...
Files:
packages/nextjs/src/utils/clerk-script.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.
Files:
packages/nextjs/src/utils/clerk-script.tsxpackages/ui/src/internal/index.ts
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Avoid barrel files (index.ts re-exports) as they can cause circular dependencies
Files:
packages/ui/src/internal/index.ts
packages/ui/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-ui-theming.mdc)
packages/ui/src/**/*.{ts,tsx}: Use element descriptors for all themable elements by applyingelementDescriptorprop to components and importing descriptors frompackages/ui/src/customizables/elementDescriptors.ts
Use theme-aware functions inelementsconfiguration to access design tokens (e.g.,{ theme } => ({ backgroundColor: theme.colors.$primary500 }))
Prefer CSS variables (e.g.,--clerk-color-primary,--clerk-spacing) for runtime customization via theclerkCssVarutility
Automatically generate color scales using the color scale generation process rather than manually defining all lightness and alpha variations (25, 50, 100, 150, 200, 300, 400, 500, 600, 700, 750, 800, 850, 900, 950 shades)
Use thecreateVariantsfunction frompackages/ui/src/styledSystem/createVariants.tsfor type-safe variant-based styling with base, variants, defaultVariants, and compoundVariants configuration
Wrap primitive components withmakeCustomizableHOC frompackages/ui/src/customizables/makeCustomizable.tsxto enable element descriptor support and theming
Apply thesxprop using either a theme-aware function(theme: InternalTheme) => StyleRuleor static style object to components for theme-aware CSS
Use state props (isLoading, hasError, isOpen, isActive) to automatically generate state classes (cl-loading, cl-error, cl-open, cl-active) for styling
Use CSSlight-dark()function via thelightDarkutility frompackages/ui/src/utils/lightDark.tsfor automatic light/dark mode support with fallbacks
Use Emotion'scssprop andThemeProviderviaInternalThemeProviderfrompackages/ui/src/styledSystem/InternalThemeProvider.tsxfor styling and theme context
UsemakeResponsivefrompackages/ui/src/customizables/makeResponsive.tsxwith breakpoints defined inpackages/ui/src/styledSystem/breakpoints.tsxfor responsive design support
UseuseDeepEqualMemoin AppearanceProvider to prevent unnecessary re-renders when appearance configuration changes
Files:
packages/ui/src/internal/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
- GitHub Check: Unit Tests (**)
- GitHub Check: Unit Tests (shared, clerk-js, RQ)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Static analysis
- GitHub Check: Integration Tests (nextjs, chrome, 16)
- GitHub Check: Integration Tests (quickstart, chrome, 15)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
- GitHub Check: Integration Tests (quickstart, chrome, 16)
- GitHub Check: Integration Tests (billing, chrome, RQ)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (handshake:staging, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/ui/src/internal/index.ts (1)
130-134: No issues found.PACKAGE_VERSIONis properly declared as a global ambient constant in TypeScript type declaration files and injected by the build configuration.Likely an incorrect or invalid review comment.
packages/nextjs/src/utils/clerk-script.tsx (1)
53-66: Verifyui.urlis guaranteed to be a string (or add a local guard) before passing into URL builders.The new narrowing correctly avoids reading
.urlfrom constructors. One remaining sharp edge:'url' in uidoesn’t ensureui.urlis a string—if upstream validation ever regresses,clerkUiScriptUrl(opts)/ attribute builders could throw.Optional local hardening (if upstream doesn’t fully guarantee types)
- const uiVersionUrl = ui && typeof ui === 'object' && 'url' in ui ? ui.url : undefined; + const uiVersionUrl = + ui && typeof ui === 'object' && 'url' in ui && typeof (ui as any).url === 'string' + ? (ui as any).url + : undefined;
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
- Change UiModule constructor args from any[] to unknown[] - Add instance type generic parameter I to UiModule (defaults to unknown) - Change appearance type defaults from any to unknown for type safety - Add @typeparam JSDoc annotations
Update the type check to use 'unknown extends A' which correctly handles both 'any' and 'unknown' type parameters, falling back to the Default type in both cases.
Summary
This PR consolidates the UI module configuration into a single
uiprop onClerkProviderthat accepts either:versionexport from@clerk/uifor hot loading with version pinningClerkUIclass constructor from@clerk/uifor direct module usage (bundled with your app)Usage Examples
Runtime Validation
Only legitimate exports from
@clerk/uiare accepted. The exports are branded with a symbol (Symbol.for('clerk:ui')) that is validated at runtime. This means:import { version } from '@clerk/ui'- acceptedimport { ClerkUI } from '@clerk/ui'- accepted{ version: "1.0.0" }- rejected (arbitrary object)"1.0.0"- rejected (string)Changes
Uitype intoUiVersionandUiModule, withUias a union of bothversionobject andClerkUIconstructor from@clerk/uiUI_BRAND_SYMBOLfor runtime validation of legitimate exportsIsomorphicClerkto detect and validate both ui typesIsomorphicClerkOptions.uito accept both typesclerkUiCtoras internal property forclerk.load()compatibility@clerk/astro,@clerk/vue,@clerk/chrome-extensionto use new patternTest plan
@clerk/reactand@clerk/sharedSummary by CodeRabbit
New Features
Updates
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.