Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Aug 1, 2025

Description

This PR refactors the API keys component to switch from client-side pagination and filtering to server-side.

  • uses existing usePageOrInfinite() hook for pagination
  • exports useAPIKeys() hook as experimental for future use
Screen.Recording.2025-11-06.at.10.46.53.AM.mov

Checklist

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

Type of change

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

Summary by CodeRabbit

  • New Features

    • Server-side pagination for API keys with visible page controls
    • Debounced search (500ms) for filtering API keys
    • Automatic refresh of list after creating or revoking a key
  • Tests

    • New integration tests covering multi-page pagination and single-page visibility
    • New unit tests for API keys component loading, rendering, and empty state

@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2025

🦋 Changeset detected

Latest commit: 86e6a07

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

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/shared Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/types Patch
@clerk/vue Patch
@clerk/localizations Patch

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

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

@vercel
Copy link

vercel bot commented Aug 1, 2025

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

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 7, 2025 7:44pm

@clerk-cookie
Copy link
Collaborator

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! 🙏

@clerk-cookie clerk-cookie added Stale and removed Stale labels Oct 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

Implements 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

Cohort / File(s) Summary
Type & API Signature Updates
packages/shared/src/types/apiKeys.ts, packages/shared/src/types/clerk.ts
Changed getAll to return ClerkPaginatedResponse<APIKeyResource> and wrapped GetAPIKeysParams with pagination params.
Core API Keys Module
packages/clerk-js/src/core/modules/apiKeys/index.ts
Switched to BaseResource._fetch, return paginated response, use convertPageToOffsetSearchParams, map paginated payload to APIKey instances.
Shared Hook (server-side)
packages/shared/src/react/hooks/useAPIKeys.ts, packages/shared/src/react/hooks/index.ts
Added useApiKeys hook with paginated/fetch modes, telemetry; exported alias __experimental_useAPIKeys.
UI Component Integrations
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx, .../utils.ts, .../CreateAPIKeyForm.tsx, .../APIKeysTable.tsx, .../APIKeyModal.tsx, .../CopyAPIKeyModal.tsx, .../RevokeAPIKeyConfirmationModal.tsx
Wired server pagination, debounced search (500ms), useAPIKeysPagination hook for invalidation; renamed components/types to PascalCase; added onRevokeSuccess callback and adjusted create/revoke flows.
Hook Removal
packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts
Removed previous client-side SWR-based useApiKeys hook and internal client-side pagination logic.
Contexts Renames
packages/clerk-js/src/ui/contexts/components/ApiKeys.ts, packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx, packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx, packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
Renamed ApiKeysContextAPIKeysContext and useApiKeysContextuseAPIKeysContext; updated imports/usages.
New / Updated Tests
packages/clerk-js/src/ui/components/ApiKeys/__tests__/ApiKeys.spec.tsx, integration/tests/machine-auth/component.test.ts, integration/testUtils/usersService.ts
Added unit tests for loading/empty/list states, Playwright integration tests for pagination behavior; test API key naming adjusted to use UUID.
Version Bump / Changeset
.changeset/bright-papayas-accept.md, package.json (manifests)
Added changeset to bump minor versions for @clerk/clerk-js and @clerk/shared.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Areas to focus:
    • packages/clerk-js/src/core/modules/apiKeys/index.ts — pagination params and response mapping
    • packages/shared/src/react/hooks/useAPIKeys.ts — paging logic, enabled flag, telemetry
    • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx & utils.ts — debounce, fetchPage wiring, invalidateAll usage
    • Renames across contexts/components — ensure all imports/exports updated consistently
    • Tests — integration tests create/cleanup and expectations for pagination counts

Possibly related PRs

Suggested labels

types, react

Suggested reviewers

  • brkalow
  • aeliox
  • panteliselef

Poem

🐰
I hopped through pages, one, two, three—
Server now counts each key for me.
Debounced searches, tidy names,
Pagination plays fairer games.
A tiny rabbit cheers: hop, deploy, wee!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: implementing server-side pagination and filtering for API keys, which is the core refactoring objective of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-2501-api-keys-server-side

📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between cb762d4 and 86e6a07.

📒 Files selected for processing (1)
  • packages/shared/src/react/hooks/useAPIKeys.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{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.ts
**/*.{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.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useAPIKeys.ts
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.ts
**/*.{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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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.ts
**/*.{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.ts
🧬 Code graph analysis (1)
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)
⏰ 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: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (5)
packages/shared/src/react/hooks/useAPIKeys.ts (5)

9-29: LGTM! Well-structured type definitions.

The type definitions are clean and follow TypeScript best practices. The conditional type for UseApiKeysReturn correctly propagates the infinite mode, and the use of PaginatedHookConfig provides proper extension of base pagination types.


31-68: LGTM! Comprehensive documentation with practical examples.

The JSDoc provides clear usage examples covering pagination, search, and infinite scroll patterns. The examples accurately reflect the hook's API surface and demonstrate real-world integration patterns.


86-93: Past critical issue resolved: default fetch now enabled.

The previous issue where hookParams was conditionally set to undefined has been fixed. The hook now correctly constructs hookParams from safeValues unconditionally and removes the !!hookParams guard from isEnabled, allowing the hook to fetch with defaults when params is omitted.

The conditional spreading on lines 89-90 appropriately excludes empty subject and query values from the API request while preserving required pagination parameters.


95-107: LGTM! Correct integration with usePagesOrInfinite.

The hook correctly delegates to usePagesOrInfinite with proper parameters:

  • Request params structured as GetAPIKeysParams
  • Fetcher uses optional chaining to handle unavailable clerk.apiKeys.getAll
  • Config flags propagated correctly (keepPreviousData, infinite, enabled)
  • Cache keys include type and subject for proper differentiation

The type assertion on line 107 is necessary due to TypeScript's inability to infer the conditional return type and is safe given the matching type structures.


84-84: No action required—telemetry pattern is consistent with established codebase convention.

The telemetry call on line 84 follows the same pattern as all other hooks in the codebase (useUser, useSession, useOrganization, etc.). Recording telemetry on every render—rather than only on mount—appears to be the established design pattern. The sampling logic within eventMethodCalled likely handles frequency concerns.


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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: Use unknown instead of any for the error type.

Per TypeScript best practices and the coding guidelines, error parameters should be typed as unknown rather than any, 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 ?? 5 appears 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 code

Then use pageSize throughout instead of perPage ?? 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bcb2f34 and be138e9.

📒 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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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 query parameter
  • 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 useAPIKeys and useAPIKeysPagination hooks 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 the useAPIKeysPagination hook 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 = ({
Copy link
Member

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.

Copy link
Member Author

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) && (
Copy link
Member

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?

Copy link
Member Author

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!

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 consistent

We calculate pagination row info with perPage ?? API_KEYS_PAGE_SIZE, but the useAPIKeys call still forwards an undefined pageSize when perPage isn’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.

📥 Commits

Reviewing files that changed from the base of the PR and between 892d7e0 and 00aa981.

📒 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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/contexts/components/ApiKeys.ts
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/UserProfile/ApiKeysPage.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/CopyApiKeyModal.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
  • packages/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 ApiKeysTable to APIKeysTable standardizes 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 APIKeysContext rename, 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 APIKeysContext and useAPIKeysContext naming, 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 APIKeyModalProps type and APIKeyModal component 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 APIKeysContext import 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, and APIKeyModal. 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 00aa981 and 4e372a1.

📒 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.ts
  • packages/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.ts
  • packages/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.ts
  • packages/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.ts
  • packages/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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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.ts
  • packages/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.ts
  • packages/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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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__nameAlreadyExists exists 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, isFetching is 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 isFetching to the APIKeysTable or 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_SIZE is 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 4e372a1 and bba3547.

📒 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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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', and spellCheck={false}, which provide optimal UX for search functionality.


209-217: LGTM! Pagination logic is sound.

The conditional rendering based on pageCount > 1 is appropriate, and the defensive Math.min(page, pageCount) on line 212 ensures the pagination component never receives an out-of-bounds page value, even though useAPIKeysPagination already handles this scenario.


236-258: LGTM! Clean wrapper implementation.

The _APIKeys component correctly uses the updated useAPIKeysContext() hook and follows the established pattern for subject determination and component composition. The export with guards is appropriate.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 | null because the component returns null when !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 localizationKeys for 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.

📥 Commits

Reviewing files that changed from the base of the PR and between bba3547 and cb762d4.

📒 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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for 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
Use const assertions for literal types: as const
Use satisfies operator 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for 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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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.tsx
  • packages/clerk-js/src/ui/components/ApiKeys/APIKeyModal.tsx
  • packages/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 ApiKeyModalProps to APIKeyModalProps aligns 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 CopyApiKeyModalProps to CopyAPIKeyModalProps and 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 APIKeyModal component with correct props, proper accessibility attributes (role='alertdialog'), localization via localizationKeys, and element descriptors for theming.

packages/clerk-js/src/ui/components/ApiKeys/APIKeysTable.tsx (1)

22-22: LGTM! Good naming consistency improvement.

Renaming ApiKeysTable to APIKeysTable properly capitalizes the API acronym, which aligns with common naming conventions for acronyms.

@blacksmith-sh

This comment has been minimized.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@wobsoriano wobsoriano merged commit cc11472 into main Nov 7, 2025
42 checks passed
@wobsoriano wobsoriano deleted the rob/user-2501-api-keys-server-side branch November 7, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants