-
Notifications
You must be signed in to change notification settings - Fork 417
feat(clerk-js): Implement server-side pagination and filtering for API keys #6453
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
Conversation
🦋 Changeset detectedLatest commit: 86e6a07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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.
|
|
Hello 👋 We currently close PRs after 60 days of inactivity. It's been 50 days since the last update here. If we missed this PR, please reply here. Otherwise, we'll close this PR in 10 days. Thanks for being a part of the Clerk community! 🙏 |
WalkthroughImplements server-side pagination and search for API keys: API surface and types updated to return paginated responses, client-side pagination removed, new shared hook and pagination utilities added, UI components wired to server pagination with debounced search and updated naming, plus tests and a version bump. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as APIKeys Component
participant Hook as useApiKeys / useAPIKeys
participant API as Clerk API (clerk.apiKeys.getAll)
User->>UI: mount / change page / type search
UI->>UI: debounce search (500ms)
UI->>Hook: fetchPage(page, query, subject)
Hook->>API: getAll({ page, limit, query, subject })
API-->>Hook: { data: [...], total_count }
Hook-->>UI: { apiKeys, page, pageCount, itemCount, isFetching }
UI->>UI: render table & pagination
alt create/revoke success
UI->>Hook: invalidateAll()
Hook->>API: re-fetch current page
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (6)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx,d.ts}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
🧬 Code graph analysis (1)packages/shared/src/react/hooks/useAPIKeys.ts (5)
⏰ 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). (4)
🔇 Additional comments (5)
Comment |
0f62bc3 to
d605cdd
Compare
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/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
116-122: Useunknowninstead ofanyfor the error type.Per TypeScript best practices and the coding guidelines, error parameters should be typed as
unknownrather thanany, then narrowed with type guards.- } catch (err: any) { + } catch (err: unknown) { if (isClerkAPIResponseError(err)) {
🧹 Nitpick comments (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
73-89: Consider extracting the default page size to a constant.The expression
perPage ?? 5appears multiple times throughout the component (lines 73, 88, 89, 208). Extract this to a constant at the top of the component to follow the DRY principle.+const DEFAULT_PAGE_SIZE = 5; + export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPageProps) => { + const pageSize = perPage ?? DEFAULT_PAGE_SIZE; const isOrg = isOrganizationId(subject); // ... rest of codeThen use
pageSizethroughout instead ofperPage ?? 5.
📜 Review details
Configuration used: Path: .coderabbit.yaml
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/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx(7 hunks)packages/clerk-js/src/ui/components/ApiKeys/utils.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/clerk-js/src/ui/components/ApiKeys/utils.ts
🧰 Additional context used
📓 Path-based instructions (9)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (2)
packages/clerk-js/src/ui/components/ApiKeys/utils.ts (1)
useAPIKeysPagination(19-61)packages/clerk-js/src/ui/elements/Pagination.tsx (1)
Pagination(123-192)
⏰ 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). (5)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (3)
59-163: Excellent implementation of debounced search and server-side pagination.The changes properly implement:
- Debounced search with 500ms delay to reduce API calls
- Server-side filtering via the
queryparameter- Proper separation of immediate UI state (
searchValue) and debounced API query (debouncedSearchValue)- Appropriate search input attributes (
type='search',autoCapitalize='none',spellCheck={false})The pagination state management through
useAPIKeysanduseAPIKeysPaginationhooks follows React best practices with proper cache invalidation.
208-216: Pagination implementation is correct.The defensive
Math.min(page, pageCount)at line 211 ensures the page number is never invalid, even during loading states. While theuseAPIKeysPaginationhook already handles page resets, this defensive coding prevents edge cases and is good practice.
228-228: Proper data invalidation on revoke.Adding the
onRevokeSuccess={invalidateAll}callback ensures the API keys list is refreshed after a successful revocation, maintaining consistency with the create flow.
| * - Adjusts page when current page exceeds available pages (e.g., after deletion) | ||
| * - Provides cache invalidation function for mutations | ||
| */ | ||
| export const useAPIKeysPagination = ({ |
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.
🙃 Let's look into consistency between API & Api. It seems they're used interchangeably and it'll be good to settle on one.
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.
we discussed before and went with API so I went with that as well! thanks
| canManageAPIKeys={(isOrg && canManageAPIKeys) || !isOrg} | ||
| /> | ||
| {itemCount > (perPage ?? 5) && ( | ||
| {(itemCount > (perPage ?? 5) || pageCount > 1) && ( |
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.
🙃 Seems the page size in useApiKeys is 10. Maybe we set a const there and reference it here?
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.
updated to use 10 to have consistency with other hooks!
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
🧹 Nitpick comments (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
72-78: Keep page size fallback consistentWe calculate pagination row info with
perPage ?? API_KEYS_PAGE_SIZE, but theuseAPIKeyscall still forwards anundefinedpageSizewhenperPageisn’t provided. If the hook’s internal default diverges from the constant, the UI will report inaccurate ranges. Passing the same fallback here keeps the source of truth aligned.Apply this diff so the hook and UI share the same default:
const { data: apiKeys, isLoading, isFetching, page, fetchPage, pageCount, count: itemCount, } = useAPIKeys({ subject, - pageSize: perPage, + pageSize: perPage ?? API_KEYS_PAGE_SIZE, query, keepPreviousData: true, enabled: isOrg ? canReadAPIKeys : true, });
📜 Review details
Configuration used: Path: .coderabbit.yaml
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)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsx(2 hunks)packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx(6 hunks)packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx(1 hunks)packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx(4 hunks)packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx(3 hunks)packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx(4 hunks)packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx(2 hunks)packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx(2 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx(2 hunks)packages/clerk-js/src/ui/contexts/components/ApiKeys.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/contexts/components/ApiKeys.tspackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsxpackages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsxpackages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsxpackages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsxpackages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
🧬 Code graph analysis (9)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsx (1)
packages/clerk-js/src/ui/elements/Modal.tsx (1)
Modal(25-108)
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx (2)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
APIKeysContext(5-5)packages/shared/src/types/clerk.ts (1)
APIKeysProps(1942-1968)
packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (1)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
useAPIKeysContext(7-20)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx (3)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
APIKeysContext(5-5)packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
APIKeysPage(55-234)packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx (1)
APIKeysPage(10-39)
packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx (1)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
APIKeysContext(5-5)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
packages/clerk-js/src/ui/types.ts (1)
APIKeysCtx(135-138)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (6)
packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx (1)
CopyAPIKeyModal(24-101)packages/clerk-js/src/ui/components/ApiKeys/utils.ts (1)
useAPIKeysPagination(19-60)packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (2)
OnCreateParams(23-27)CreateAPIKeyForm(120-260)packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx (1)
APIKeysTable(22-120)packages/clerk-js/src/ui/elements/Pagination.tsx (1)
Pagination(123-192)packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
useAPIKeysContext(7-20)
packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsx (1)
APIKeyModal(36-44)
packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsx (1)
APIKeyModal(36-44)
⏰ 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). (4)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx (1)
22-22: LGTM - Naming consistency improvement.The component rename from
ApiKeysTabletoAPIKeysTablestandardizes the acronym capitalization, aligning with common PascalCase conventions for well-known acronyms like API, URL, and HTML.packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx (1)
13-13: LGTM - Context import and usage updated consistently.The import and provider usage correctly reflect the
APIKeysContextrename, maintaining consistency with the updated context export.Also applies to: 111-113
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
5-11: LGTM - Context and hook exports renamed consistently.The context creation, hook export, and error message all correctly reflect the updated
APIKeysContextanduseAPIKeysContextnaming, ensuring a consistent public API surface.packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx (1)
3-3: LGTM - Provider updated to use renamed context.The import and provider usage correctly reference
APIKeysContext, maintaining consistency with the context rename while preserving the existing props structure.Also applies to: 28-33
packages/clerk-js/src/ui/components/ApiKeys/ApiKeyModal.tsx (1)
6-6: LGTM - Modal component and props type renamed consistently.The
APIKeyModalPropstype andAPIKeyModalcomponent export correctly apply the standardized API acronym capitalization, with no changes to the modal's behavior or styling logic.Also applies to: 36-36
packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx (1)
3-3: LGTM - Context import and provider updated.The
APIKeysContextimport and provider usage align with the context rename, properly wrapping the API keys page component.Also applies to: 31-36
packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx (1)
13-13: LGTM - Copy modal component and dependencies renamed consistently.All references to the modal component, props type, and import path correctly reflect the standardized naming:
CopyAPIKeyModal,CopyAPIKeyModalProps, andAPIKeyModal. The component logic remains unchanged.Also applies to: 15-15, 24-31, 54-54, 99-99
packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (1)
3-3: LGTM - Form component, props, and context hook renamed consistently.The import, props interface (
CreateAPIKeyFormProps), component export (CreateAPIKeyForm), and hook usage (useAPIKeysContext) all correctly apply the standardized API acronym capitalization. The form logic and field handling remain unchanged.Also applies to: 29-29, 120-123
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
📜 Review details
Configuration used: Path: .coderabbit.yaml
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 (4)
packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx(3 hunks)packages/clerk-js/src/ui/components/ApiKeys/utils.ts(1 hunks)packages/shared/src/react/hooks/index.ts(1 hunks)packages/shared/src/react/hooks/useAPIKeys.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/shared/src/react/hooks/index.ts
- packages/clerk-js/src/ui/components/ApiKeys/utils.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/shared/src/react/hooks/useAPIKeys.tspackages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx
🧬 Code graph analysis (2)
packages/shared/src/react/hooks/useAPIKeys.ts (5)
packages/shared/src/react/types.ts (2)
PaginatedHookConfig(89-102)PaginatedResources(13-79)packages/shared/src/types/clerk.ts (1)
GetAPIKeysParams(1970-1973)packages/shared/src/types/apiKeys.ts (1)
APIKeyResource(5-22)packages/shared/src/react/hooks/usePagesOrInfinite.ts (2)
useWithSafeValues(74-94)usePagesOrInfinite(146-344)packages/shared/src/telemetry/events/method-called.ts (1)
eventMethodCalled(13-25)
packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx (1)
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
useAPIKeysContext(7-20)
⏰ 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)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
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/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
108-124: Localize the error message.Line 120 uses a hard-coded string
'API Key name already exists'which violates the guideline: "Do not render hard-coded values; all user-facing strings must be localized using provided localization methods."As per coding guidelines
Apply this diff to localize the error:
if (err.status === 409) { - card.setError('API Key name already exists'); + card.setError(t(localizationKeys('apiKeys.error__nameAlreadyExists'))); }Note: You'll need to ensure the localization key
apiKeys.error__nameAlreadyExistsexists in your localization resources.
🧹 Nitpick comments (2)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (2)
60-78: Consider showing search loading state.The debounced search and server-side filtering implementation is solid. However,
isFetchingis available but not used in the UI to indicate when a search is in progress. Users might benefit from visual feedback during the debounce period or while the search executes.For example, you could pass
isFetchingto theAPIKeysTableor show a subtle indicator in the search input:<InputWithIcon placeholder={t(localizationKeys('apiKeys.action__search'))} leftIcon={ <Icon icon={MagnifyingGlass} sx={t => ({ color: t.colors.$colorMutedForeground })} /> } value={searchValue} type='search' autoCapitalize='none' spellCheck={false} onChange={e => setSearchValue(e.target.value)} elementDescriptor={descriptors.apiKeysSearchInput} + isLoading={isFetching} />
89-90: Extract repeated expression for clarity.The fallback
perPage ?? API_KEYS_PAGE_SIZEis repeated in both pagination calculations. Extracting it to a local constant improves maintainability.+ const effectivePageSize = perPage ?? API_KEYS_PAGE_SIZE; - const startingRow = itemCount > 0 ? Math.max(0, (page - 1) * (perPage ?? API_KEYS_PAGE_SIZE)) + 1 : 0; - const endingRow = Math.min(page * (perPage ?? API_KEYS_PAGE_SIZE), itemCount); + const startingRow = itemCount > 0 ? Math.max(0, (page - 1) * effectivePageSize) + 1 : 0; + const endingRow = Math.min(page * effectivePageSize, itemCount);
📜 Review details
Configuration used: Path: .coderabbit.yaml
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)
integration/tests/machine-auth/component.test.ts(1 hunks)packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx(6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- integration/tests/machine-auth/component.test.ts
🧰 Additional context used
📓 Path-based instructions (9)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (5)
packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx (1)
CopyAPIKeyModal(24-101)packages/clerk-js/src/ui/components/ApiKeys/utils.ts (1)
useAPIKeysPagination(19-60)packages/clerk-js/src/ui/components/ApiKeys/CreateAPIKeyForm.tsx (2)
OnCreateParams(23-27)CreateAPIKeyForm(120-260)packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx (1)
APIKeysTable(22-120)packages/clerk-js/src/ui/contexts/components/ApiKeys.ts (1)
useAPIKeysContext(7-20)
⏰ 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). (3)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (4)
52-53: LGTM! Good use of constants.The debounce delay and page size are well-chosen and properly extracted as constants. The 500ms debounce provides good UX balance between responsiveness and reducing unnecessary API calls.
160-164: LGTM! Proper search input attributes.The search input correctly uses
type='search',autoCapitalize='none', andspellCheck={false}, which provide optimal UX for search functionality.
209-217: LGTM! Pagination logic is sound.The conditional rendering based on
pageCount > 1is appropriate, and the defensiveMath.min(page, pageCount)on line 212 ensures the pagination component never receives an out-of-bounds page value, even thoughuseAPIKeysPaginationalready handles this scenario.
236-258: LGTM! Clean wrapper implementation.The
_APIKeyscomponent correctly uses the updateduseAPIKeysContext()hook and follows the established pattern for subject determination and component composition. The export with guards is appropriate.
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
🧹 Nitpick comments (4)
packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx (1)
36-44: Add explicit return type annotation for public component.The component logic and rename are correct, but as a public/exported API, it should have an explicit return type annotation per coding guidelines.
Apply this diff to add the return type:
-export const APIKeyModal = ({ modalRoot, containerSx, ...modalProps }: APIKeyModalProps) => { +export const APIKeyModal = ({ modalRoot, containerSx, ...modalProps }: APIKeyModalProps): JSX.Element => { return (packages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx (2)
24-31: Add explicit return type annotation for public component.The component declaration and rename are correct, but as a public/exported API, it should have an explicit return type annotation per coding guidelines.
Apply this diff to add the return type:
export const CopyAPIKeyModal = ({ isOpen, onOpen, onClose, apiKeyName, apiKeySecret, modalRoot, -}: CopyAPIKeyModalProps) => { +}: CopyAPIKeyModalProps): JSX.Element | null => { const apiKeyField = useFormControl('apiKeySecret', apiKeySecret, {Note: The return type is
JSX.Element | nullbecause the component returnsnullwhen!isOpen(line 50).
80-80: TODO comment: Unified Input + icon button component.There's a tracked TODO for using a unified Input with appended icon button component instead of the current ClipboardInput implementation.
Would you like me to open a new issue to track this improvement, or is this already being addressed elsewhere in the codebase?
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsx (1)
43-45: Consider localizing table headers.The table headers contain hardcoded strings that should use
localizationKeysfor consistency with the rest of the component and to support internationalization. As per coding guidelines, all user-facing strings should be localized.Example:
<Thead> <Tr> - <Th>Name</Th> - <Th>Last used</Th> - {canManageAPIKeys && <Th>Actions</Th>} + <Th localizationKey={localizationKeys('apiKeys.table.header__name')} /> + <Th localizationKey={localizationKeys('apiKeys.table.header__lastUsed')} /> + {canManageAPIKeys && <Th localizationKey={localizationKeys('apiKeys.table.header__actions')} />} </Tr> </Thead>Based on coding guidelines.
📜 Review details
Configuration used: Path: .coderabbit.yaml
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 (3)
packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx(2 hunks)packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsx(1 hunks)packages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx(4 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsxpackages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsxpackages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx
🧬 Code graph analysis (2)
packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx (1)
packages/clerk-js/src/ui/elements/Modal.tsx (1)
Modal(25-108)
packages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx (1)
packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx (1)
APIKeyModal(36-44)
⏰ 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). (5)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx (1)
6-8: LGTM: Type definition is correct.The rename from
ApiKeyModalPropstoAPIKeyModalPropsaligns with the naming consistency improvements across the API keys components.packages/clerk-js/src/ui/components/ApiKeys/CopyAPIKeyModal.tsx (2)
13-22: LGTM: Import and type definition are correct.The rename from
CopyApiKeyModalPropstoCopyAPIKeyModalPropsand the updated import align with the naming consistency improvements across the API keys components. The type definition properly captures all required props.
54-99: LGTM: JSX structure and APIKeyModal usage are correct.The updated JSX properly uses the renamed
APIKeyModalcomponent with correct props, proper accessibility attributes (role='alertdialog'), localization vialocalizationKeys, and element descriptors for theming.packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsx (1)
22-22: LGTM! Good naming consistency improvement.Renaming
ApiKeysTabletoAPIKeysTableproperly capitalizes the API acronym, which aligns with common naming conventions for acronyms.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Description
This PR refactors the API keys component to switch from client-side pagination and filtering to server-side.
usePageOrInfinite()hook for paginationuseAPIKeys()hook as experimental for future useScreen.Recording.2025-11-06.at.10.46.53.AM.mov
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Tests