-
Notifications
You must be signed in to change notification settings - Fork 359
Introduce useCheckout #6195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Introduce useCheckout #6195
Conversation
🦋 Changeset detectedLatest commit: f501d70 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 Git ↗︎ 1 Skipped Deployment
|
!snapshot |
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.1.3-snapshot.v20250626091436 --save-exact
npm i @clerk/astro@2.9.3-snapshot.v20250626091436 --save-exact
npm i @clerk/backend@2.2.1-snapshot.v20250626091436 --save-exact
npm i @clerk/chrome-extension@2.5.1-snapshot.v20250626091436 --save-exact
npm i @clerk/clerk-js@5.70.0-snapshot.v20250626091436 --save-exact
npm i @clerk/elements@0.23.35-snapshot.v20250626091436 --save-exact
npm i @clerk/clerk-expo@2.14.0-snapshot.v20250626091436 --save-exact
npm i @clerk/expo-passkeys@0.3.12-snapshot.v20250626091436 --save-exact
npm i @clerk/express@1.7.2-snapshot.v20250626091436 --save-exact
npm i @clerk/fastify@2.4.2-snapshot.v20250626091436 --save-exact
npm i @clerk/localizations@3.17.1-snapshot.v20250626091436 --save-exact
npm i @clerk/nextjs@6.24.0-snapshot.v20250626091436 --save-exact
npm i @clerk/nuxt@1.7.3-snapshot.v20250626091436 --save-exact
npm i @clerk/clerk-react@5.33.0-snapshot.v20250626091436 --save-exact
npm i @clerk/react-router@1.6.2-snapshot.v20250626091436 --save-exact
npm i @clerk/remix@4.8.3-snapshot.v20250626091436 --save-exact
npm i @clerk/shared@3.10.0-snapshot.v20250626091436 --save-exact
npm i @clerk/tanstack-react-start@0.18.1-snapshot.v20250626091436 --save-exact
npm i @clerk/testing@1.8.3-snapshot.v20250626091436 --save-exact
npm i @clerk/themes@2.2.52-snapshot.v20250626091436 --save-exact
npm i @clerk/types@4.62.0-snapshot.v20250626091436 --save-exact
npm i @clerk/vue@1.8.10-snapshot.v20250626091436 --save-exact |
!snapshot |
# Conflicts: # integration/tests/pricing-table.test.ts # packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx # packages/shared/src/react/hooks/index.ts # packages/testing/src/playwright/unstable/page-objects/checkout.ts
0423d2b
to
61fe81d
Compare
'@clerk/types': minor | ||
--- | ||
|
||
wip |
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.
I will update this :)
📝 WalkthroughWalkthroughThis change introduces an experimental checkout API and related infrastructure across Clerk's JavaScript, React, and Next.js packages. It adds new types, interfaces, and methods to support a commerce checkout lifecycle, including state management, error handling, and context propagation. The core logic includes a checkout manager for handling state, concurrency, and subscriptions, as well as a React hook ( Suggested reviewers
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
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: 6
🧹 Nitpick comments (3)
.changeset/stale-pillows-sneeze.md (1)
9-9
: Update the changeset description.The placeholder "wip" description should be replaced with a meaningful description of the experimental checkout feature being introduced across these packages.
Consider updating to something like:
-wip +Introduce experimental checkout API with useCheckout hook and CheckoutProviderpackages/shared/src/react/hooks/useCheckout.ts (1)
72-78
: Consider returning error states instead of throwing.Throwing errors in React hooks can cause issues with error boundaries and component lifecycle. Consider returning error states instead.
- if (!user) { - throw new Error('Clerk: User is not authenticated'); - } - - if (forOrganization === 'organization' && !organization) { - throw new Error('Clerk: Use `setActive` to set the organization'); - } + if (!user) { + return { + ...nullProperties, + error: new Error('Clerk: User is not authenticated'), + // ... other properties + }; + }packages/clerk-js/src/core/modules/checkout/manager.ts (1)
122-166
: Robust operation execution with concurrency control.The implementation handles concurrent operations well with deduplication. Consider adding a type guard for the error casting to ensure type safety:
} catch (error) { // Cast error to expected type and update state - const clerkError = error as ClerkAPIResponseError; + const clerkError = error as ClerkAPIResponseError | Error; updateCacheState({ [isRunningField]: false, error: clerkError }); throw error; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (23)
.changeset/stale-pillows-sneeze.md
(1 hunks)packages/clerk-js/src/core/clerk.ts
(4 hunks)packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
(1 hunks)packages/clerk-js/src/core/modules/checkout/instance.ts
(1 hunks)packages/clerk-js/src/core/modules/checkout/manager.ts
(1 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
(2 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
(5 hunks)packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
(1 hunks)packages/clerk-js/src/ui/components/Checkout/index.tsx
(1 hunks)packages/clerk-js/src/ui/components/Checkout/parts.tsx
(5 hunks)packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
(2 hunks)packages/nextjs/src/client-boundary/hooks.ts
(1 hunks)packages/nextjs/src/index.ts
(1 hunks)packages/react/src/contexts/ClerkContextProvider.tsx
(2 hunks)packages/react/src/hooks/index.ts
(1 hunks)packages/react/src/isomorphicClerk.ts
(1 hunks)packages/shared/src/error.ts
(10 hunks)packages/shared/src/react/contexts.tsx
(4 hunks)packages/shared/src/react/hooks/index.ts
(1 hunks)packages/shared/src/react/hooks/useCheckout.ts
(1 hunks)packages/shared/src/react/index.ts
(1 hunks)packages/types/src/api.ts
(1 hunks)packages/types/src/clerk.ts
(4 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
`**/*.{js,ts,tsx,jsx}`: All code must pass ESLint checks with the project's configuration. Use Prettier for consistent code formatting.
**/*.{js,ts,tsx,jsx}
: All code must pass ESLint checks with the project's configuration.
Use Prettier for consistent code formatting.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/shared/src/react/index.ts
packages/shared/src/react/hooks/index.ts
packages/nextjs/src/client-boundary/hooks.ts
packages/react/src/hooks/index.ts
packages/react/src/isomorphicClerk.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
packages/react/src/contexts/ClerkContextProvider.tsx
packages/types/src/api.ts
packages/shared/src/react/contexts.tsx
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/error.ts
packages/clerk-js/src/ui/components/Checkout/parts.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
packages/types/src/clerk.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/core/modules/checkout/instance.ts
packages/clerk-js/src/core/modules/checkout/manager.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
`**/*.{ts,tsx}`: Maintain comprehensive JSDoc comments for public APIs.
**/*.{ts,tsx}
: Maintain comprehensive JSDoc comments for public APIs.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/shared/src/react/index.ts
packages/shared/src/react/hooks/index.ts
packages/nextjs/src/client-boundary/hooks.ts
packages/react/src/hooks/index.ts
packages/react/src/isomorphicClerk.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
packages/react/src/contexts/ClerkContextProvider.tsx
packages/types/src/api.ts
packages/shared/src/react/contexts.tsx
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/error.ts
packages/clerk-js/src/ui/components/Checkout/parts.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
packages/types/src/clerk.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/core/modules/checkout/instance.ts
packages/clerk-js/src/core/modules/checkout/manager.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
`packages/**`: All publishable packages under the @clerk namespace must be located in the packages/ directory.
packages/**
: All publishable packages under the @clerk namespace must be located in the packages/ directory.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/global.mdc)
List of files the instruction was applied to:
packages/shared/src/react/index.ts
packages/shared/src/react/hooks/index.ts
packages/nextjs/src/client-boundary/hooks.ts
packages/react/src/hooks/index.ts
packages/react/src/isomorphicClerk.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
packages/react/src/contexts/ClerkContextProvider.tsx
packages/types/src/api.ts
packages/shared/src/react/contexts.tsx
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/error.ts
packages/clerk-js/src/ui/components/Checkout/parts.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
packages/types/src/clerk.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/core/modules/checkout/instance.ts
packages/clerk-js/src/core/modules/checkout/manager.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
`**/index.ts`: Use index.ts files for clean imports but avoid deep barrel exports.
**/index.ts
: Use index.ts files for clean imports but avoid deep barrel exports.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)
List of files the instruction was applied to:
packages/shared/src/react/index.ts
packages/shared/src/react/hooks/index.ts
packages/react/src/hooks/index.ts
packages/nextjs/src/index.ts
`**/*.ts`: Always define explicit return types for functions, especially public ...
**/*.ts
: Always define explicit return types for functions, especially public APIs.
Use proper type annotations for variables and parameters where inference isn't clear.
Avoidany
type; preferunknown
when type is uncertain, then narrow with type guards.
Useinterface
for object shapes that might be extended; usetype
for unions, primitives, and computed types.
Preferreadonly
properties for immutable data structures.
Useprivate
for internal implementation details,protected
for inheritance, andpublic
explicitly for clarity in public APIs.
Prefer composition and interfaces over deep inheritance chains; use mixins for shared behavior.
Use ES6 imports/exports consistently; avoid barrel files (index.ts re-exports) to prevent circular dependencies.
Use type-only imports (import type { ... }) where possible.
Useas const
for literal types and thesatisfies
operator for type checking without widening.
Enable--incremental
and--tsBuildInfoFile
for faster builds.
Use ESLint with @typescript-eslint/recommended rules and Prettier for formatting.
Use lint-staged and Husky for pre-commit checks.
Use type-coverage to measure type safety.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)
List of files the instruction was applied to:
packages/shared/src/react/index.ts
packages/shared/src/react/hooks/index.ts
packages/nextjs/src/client-boundary/hooks.ts
packages/react/src/hooks/index.ts
packages/react/src/isomorphicClerk.ts
packages/types/src/api.ts
packages/nextjs/src/index.ts
packages/shared/src/react/hooks/useCheckout.ts
packages/shared/src/error.ts
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
packages/types/src/clerk.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/core/modules/checkout/instance.ts
packages/clerk-js/src/core/modules/checkout/manager.ts
`**/*.{jsx,tsx}`: Always use functional components with hooks instead of class c...
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components.
Follow PascalCase naming for components; the filename and component name should match.
Limit component size to 150-200 lines; extract logic into custom hooks.
Export components as named exports for better tree-shaking.
One component per file with matching filename and component name.
Co-locate related files (component, test, stories) in the same directory.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
packages/react/src/contexts/ClerkContextProvider.tsx
packages/shared/src/react/contexts.tsx
packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
packages/clerk-js/src/ui/components/Checkout/index.tsx
packages/clerk-js/src/ui/components/Checkout/parts.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
`**/*.{test,spec}.{js,ts,tsx,jsx}`: Unit tests are required for all new functionality.
**/*.{test,spec}.{js,ts,tsx,jsx}
: Unit tests are required for all new functionality.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
`**/__tests__/**/*.{js,ts,tsx,jsx}`: Test files should be co-located with source files or in `__tests__` directories.
**/__tests__/**/*.{js,ts,tsx,jsx}
: Test files should be co-located with source files or in__tests__
directories.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)
List of files the instruction was applied to:
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
🧠 Learnings (24)
📓 Common learnings
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
packages/shared/src/react/index.ts (2)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Export React components as named exports in .jsx or .tsx files to enable better tree-shaking and optimize bundle size.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Use Context API for global state such as theme or authentication, and consider dedicated state management solutions for more complex global state needs.
packages/shared/src/react/hooks/index.ts (5)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Export React components as named exports in .jsx or .tsx files to enable better tree-shaking and optimize bundle size.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Use ES6 module syntax (import/export) consistently for maintainability and compatibility.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Use index.ts files for clean imports, but avoid deep barrel exports to prevent import cycles and maintain clarity.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Follow a performance checklist: use type-only imports, ensure exports are tree-shaking friendly, avoid circular dependencies, and keep type computations efficient.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Avoid barrel files (index.ts re-exports) as they can introduce circular dependencies; instead, import directly from modules.
packages/nextjs/src/client-boundary/hooks.ts (6)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Add the 'use client' directive at the top of files that require client-side features in Next.js.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
.changeset/stale-pillows-sneeze.md (9)
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: jacekradko
PR: clerk/javascript#5905
File: .changeset/six-ears-wash.md:1-3
Timestamp: 2025-06-26T03:27:05.511Z
Learning: In the Clerk JavaScript repository, changeset headers support single quotes syntax (e.g., '@clerk/backend': minor) and work fine with their current changesets integration, so there's no need to change them to double quotes.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/global.mdc:0-0
Timestamp: 2025-06-23T12:25:34.662Z
Learning: All packages published from this repository must use the @clerk namespace.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Backend utilities are isolated in @clerk/backend, which is independent and used for server-side operations.
packages/react/src/hooks/index.ts (6)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Export React components as named exports in .jsx or .tsx files to enable better tree-shaking and optimize bundle size.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
packages/react/src/isomorphicClerk.ts (7)
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx (8)
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Follow a performance checklist: use type-only imports, ensure exports are tree-shaking friendly, avoid circular dependencies, and keep type computations efficient.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Use type-only imports (import type { ... }) to optimize performance and avoid unnecessary code inclusion.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Use useState for simple local state and useReducer for complex state logic in React functional components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use Link component for client-side navigation, useRouter hook for programmatic navigation in Client Components, and redirect function for server-side redirects.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use Suspense boundaries and loading.tsx files for granular and instant loading states during navigation.
packages/react/src/contexts/ClerkContextProvider.tsx (6)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
packages/types/src/api.ts (6)
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use TypeScript interfaces for API response types and document API endpoints accordingly.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-23T12:25:30.457Z
Learning: Error handling should use proper TypeScript error types, provide meaningful messages, and include error recovery suggestions.
packages/shared/src/react/contexts.tsx (5)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
packages/nextjs/src/index.ts (3)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Add the 'use client' directive at the top of files that require client-side features in Next.js.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Export React components as named exports in .jsx or .tsx files to enable better tree-shaking and optimize bundle size.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use Link component for client-side navigation, useRouter hook for programmatic navigation in Client Components, and redirect function for server-side redirects.
packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx (6)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
packages/clerk-js/src/ui/components/Checkout/index.tsx (6)
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use Suspense boundaries and loading.tsx files for granular and instant loading states during navigation.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:101-116
Timestamp: 2025-06-18T21:06:15.954Z
Learning: The Spinner component in packages/clerk-js has built-in accessibility attributes including aria-busy and aria-live='polite', making additional aria-label or screen reader text unnecessary for loading states.
packages/shared/src/react/hooks/useCheckout.ts (6)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Leverage TypeScript's type inference and use proper type definitions for props, state, event handlers, and generics in .tsx files to ensure type safety.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Follow a performance checklist: use type-only imports, ensure exports are tree-shaking friendly, avoid circular dependencies, and keep type computations efficient.
packages/shared/src/error.ts (10)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-23T12:25:30.457Z
Learning: Maintain comprehensive JSDoc comments for all public APIs to improve documentation and developer experience.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use TypeScript interfaces for API response types and document API endpoints accordingly.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-23T12:25:30.457Z
Learning: Error handling should use proper TypeScript error types, provide meaningful messages, and include error recovery suggestions.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-23T12:25:30.457Z
Learning: All public APIs must be documented with JSDoc, and usage examples should be provided in documentation.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: In TypeScript, always define explicit return types for functions, especially for public APIs, to ensure type safety and clarity.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Use custom error classes that extend Error for domain-specific error handling and to provide additional context.
packages/clerk-js/src/ui/components/Checkout/parts.tsx (10)
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Components in .jsx or .tsx files should be focused on a single responsibility and kept under 150-200 lines; extract logic into custom hooks to maintain readability and reusability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Optimize rendering in React by using React.memo for expensive components, useCallback for handlers, useMemo for expensive computations, and implement virtualization for large lists.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Use error boundaries in React to catch and handle errors gracefully, providing proper error messages and fallbacks.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-23T12:25:57.184Z
Learning: Implement robust form validation, error states, and error messages in React forms, ensuring proper submission and reset behavior.
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx (5)
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts (1)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
packages/types/src/clerk.ts (9)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-23T12:25:50.109Z
Learning: Use TypeScript interfaces for API response types and document API endpoints accordingly.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Use type-only imports (import type { ... }) to optimize performance and avoid unnecessary code inclusion.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Follow a performance checklist: use type-only imports, ensure exports are tree-shaking friendly, avoid circular dependencies, and keep type computations efficient.
packages/clerk-js/src/core/clerk.ts (10)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: dstaley
PR: clerk/javascript#6116
File: .changeset/tangy-garlics-say.md:1-2
Timestamp: 2025-06-13T16:09:53.061Z
Learning: In the Clerk JavaScript repository, contributors create intentionally empty changeset files (containing only the YAML delimiters) when a PR touches only non-published parts of the codebase (e.g., sandbox assets). This signals that no package release is required, so such changesets should not be flagged as missing content.
Learnt from: dstaley
PR: clerk/javascript#6100
File: packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx:121-124
Timestamp: 2025-06-16T17:08:58.414Z
Learning: The @clerk/clerk-js package only supports browsers released in the last two years (since May 8, 2023), so modern CSS features like color-mix() are fully supported across all target browsers without requiring fallbacks.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:84-88
Timestamp: 2025-06-18T16:32:03.760Z
Learning: In the Clerk JavaScript codebase, navigation errors from `navigate` and `__experimental_navigateToTask` are generally not caught and handled at the call site. The `navigateToTask` method primarily performs navigation and `session.reload` (GET request), and these operations don't require special error surfacing in the UI components.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Each framework integration package (e.g., @clerk/nextjs, @clerk/clerk-react, @clerk/vue) is designed to provide idiomatic support for its respective framework.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Backend utilities are isolated in @clerk/backend, which is independent and used for server-side operations.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
packages/clerk-js/src/core/modules/checkout/instance.ts (3)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
packages/clerk-js/src/core/modules/checkout/manager.ts (3)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: wobsoriano
PR: clerk/javascript#5858
File: packages/clerk-js/src/core/modules/apiKeys/index.ts:84-97
Timestamp: 2025-06-10T17:35:08.986Z
Learning: In the APIKeys service methods (packages/clerk-js/src/core/modules/apiKeys/index.ts), error handling is intentionally delegated to the component level rather than being implemented within the service methods themselves. This architectural pattern allows calling components to handle errors according to their specific UI needs.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (5)
Learnt from: panteliselef
PR: clerk/javascript#6097
File: packages/clerk-js/src/ui/elements/LineItems.tsx:89-89
Timestamp: 2025-06-10T09:38:56.214Z
Learning: In packages/clerk-js/src/ui/elements/LineItems.tsx, the Title component's React.forwardRef should use HTMLTableCellElement as the generic type parameter, even though it renders a Dt element. This is the correct implementation according to the codebase maintainer.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/index.tsx:64-83
Timestamp: 2025-06-18T16:33:36.764Z
Learning: In SessionTasks component at packages/clerk-js/src/ui/components/SessionTasks/index.tsx, the useEffect that checks for pending tasks should only run on mount (not react to currentTask/status changes) to handle browser back navigation edge cases without interfering with normal task completion flow managed by nextTask().
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Framework packages depend on @clerk/clerk-js for core functionality, while @clerk/shared and @clerk/types provide common utilities and TypeScript definitions used across packages.
Learnt from: LauraBeatris
PR: clerk/javascript#6117
File: packages/clerk-js/src/ui/components/SessionTasks/tasks/ForceOrganizationSelection.tsx:17-21
Timestamp: 2025-06-18T23:27:13.537Z
Learning: In Clerk's JavaScript codebase, query errors from hooks like useOrganizationList are not typically handled in AIO (All-in-One) components. Error handling may be connected with the Card context instead, suggesting a centralized error handling approach rather than component-level error handling.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-23T12:26:09.855Z
Learning: Use type-only imports (import type { ... }) to optimize performance and avoid unnecessary code inclusion.
🧬 Code Graph Analysis (4)
packages/types/src/api.ts (1)
packages/shared/src/error.ts (1)
ClerkAPIResponseError
(162-196)
packages/shared/src/react/contexts.tsx (1)
packages/types/src/commerce.ts (1)
CommerceSubscriptionPlanPeriod
(20-20)
packages/shared/src/error.ts (3)
packages/types/src/api.ts (3)
ClerkAPIResponseError
(50-57)ClerkRuntimeError
(42-45)ClerkAPIError
(4-40)packages/clerk-js/src/core/resources/Error.ts (2)
ClerkAPIResponseError
(3-3)ClerkRuntimeError
(2-2)packages/types/src/json.ts (1)
ClerkAPIErrorJSON
(339-362)
packages/clerk-js/src/core/clerk.ts (2)
packages/types/src/clerk.ts (2)
__experimental_CheckoutOptions
(72-76)__experimental_CheckoutInstance
(78-85)packages/clerk-js/src/core/modules/checkout/instance.ts (1)
createCheckoutInstance
(87-87)
🪛 ESLint
packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx
[error] 25-25: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
[error] 26-26: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts
[error] 460-460: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
⏰ Context from checks skipped due to timeout of 90000ms (24)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (nextjs, chrome, 13)
- GitHub Check: Integration Tests (tanstack-react-router, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (expo-web, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (elements, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (quickstart, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Unit Tests (22, **)
- GitHub Check: Static analysis
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (40)
packages/types/src/api.ts (1)
47-57
: Well-designed error interface that follows TypeScript best practices.The
ClerkAPIResponseError
interface is properly structured with:
- Correct inheritance from
Error
- Discriminator property
clerkError: true
for type narrowing- Appropriate optional properties marked with
?
- Consistent with existing
ClerkAPIError
usage- Comprehensive JSDoc documentation
The interface integrates well with the existing implementation in
packages/shared/src/error.ts
.packages/shared/src/react/index.ts (1)
17-17
: Export follows established experimental feature patterns.The addition of
__experimental_CheckoutProvider
maintains consistency with the existing export structure and follows the established naming convention for experimental features.packages/shared/src/react/hooks/index.ts (1)
15-15
: Export follows established patterns for experimental hooks.The
useCheckout
export with__experimental_
alias maintains perfect consistency with other experimental hook exports in the file and follows proper ES6 module syntax.packages/nextjs/src/client-boundary/hooks.ts (1)
14-15
: Next.js integration follows established patterns.The addition of
__experimental_useCheckout
and__experimental_CheckoutProvider
exports maintains consistency with:
- Proper 'use client' directive for client-side functionality
- Re-export pattern from
@clerk/clerk-react
- Experimental feature naming conventions
- Framework integration approach
packages/react/src/hooks/index.ts (1)
13-14
: LGTM! Clean export additions for experimental checkout feature.The new experimental exports follow the established pattern and are appropriately prefixed to indicate their experimental status.
packages/react/src/isomorphicClerk.ts (1)
708-710
: LGTM! Consistent forwarding method implementation.The method follows the established pattern for experimental features, properly forwards parameters, and uses safe optional chaining.
packages/nextjs/src/index.ts (1)
57-58
: LGTM! Proper Next.js app router export pattern.The experimental exports are correctly added following the explicit export pattern required for Next.js app router compatibility.
packages/react/src/contexts/ClerkContextProvider.tsx (1)
98-105
: Let's first locate how and whereCheckoutProvider
is imported to trace its implementation:#!/bin/bash # 1) Show import of CheckoutProvider in the context provider file rg -n "CheckoutProvider" -C2 packages/react/src/contexts/ClerkContextProvider.tsx # 2) Search for any file names containing "checkout" under the react package fd -I -t f "checkout" -e tsx -p packages/react/srcpackages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx (2)
1-1
: LGTM! Clean transition to shared checkout hook.The import change from local context to the experimental shared hook follows the broader refactor to centralize checkout state management.
21-21
: LGTM! Consistent usage of the new shared hook.The component now uses the centralized
useCheckout()
hook instead of the local context, maintaining the same functionality while improving state management consistency.packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx (2)
2-2
: Import follows experimental naming convention correctly.The import alias correctly follows the pattern for experimental features and maintains clarity.
58-65
: ```shell
#!/bin/bashShow CoreClerkContextWrapper implementation around CheckoutProvider
rg -n "CoreClerkContextWrapper" -C 30 --type ts packages/clerk-js/src/ui/contexts/CoreClerkContextWrapper.tsx
</details> <details> <summary>packages/shared/src/react/contexts.tsx (5)</summary> `6-6`: **Import is correctly typed and sourced.** The import of `CommerceSubscriptionPlanPeriod` from `@clerk/types` is appropriate and matches the usage in the `UseCheckoutOptions` type. --- `27-31`: **Type definition is well-structured.** The `UseCheckoutOptions` type has a clear interface with optional organization scope and required plan identification properties. The use of the imported `CommerceSubscriptionPlanPeriod` type ensures consistency. --- `33-33`: **Context creation follows established pattern.** The `CheckoutContext` and `useCheckoutContext` are created using the same `createContextAndHook` pattern as other contexts in this file, ensuring consistency. --- `35-37`: **Provider implementation is clean and consistent.** The `__experimental_CheckoutProvider` follows the same pattern as other providers in the codebase, properly spreading props and wrapping children with the context provider. --- `117-118`: **Exports follow experimental naming convention.** The exports correctly use the experimental prefix and expose the necessary hooks and components for external consumption. </details> <details> <summary>packages/clerk-js/src/ui/components/Checkout/index.tsx (2)</summary> `26-46`: **Excellent consolidation of checkout states into unified stage.** The refactoring consolidates multiple checkout states into a single `awaiting_initialization` stage with conditional rendering based on `FetchStatus`. This approach is cleaner and more maintainable than having separate stages for each state. The status handling covers all necessary scenarios: - `fetching`: Loading spinner with proper styling - `invalid_plan_change`: Plan validation error - `missing_payer_email`: Email collection form - `error`: Generic error display --- `52-52`: **Stage rename improves semantic clarity.** The rename from `ready` to `awaiting_confirmation` better describes the stage's purpose and aligns with the new naming convention used for `awaiting_initialization`. </details> <details> <summary>packages/clerk-js/src/core/clerk.ts (4)</summary> `18-19`: **LGTM: Experimental checkout types imported correctly.** The imports follow the established pattern for experimental features and properly bring in the necessary TypeScript interfaces for checkout functionality. --- `141-141`: **LGTM: Import follows established module pattern.** The import of `createCheckoutInstance` is consistent with how other module functions are imported in this file. --- `201-201`: **LGTM: Private property for lazy initialization.** The private `_checkout` property correctly uses the interface type and follows the caching pattern used elsewhere in the class (similar to `_billing` and `_apiKeys` static properties). --- `344-349`: **LGTM: Experimental checkout method properly implemented.** The implementation correctly follows the lazy initialization pattern: - Checks if the cached function exists - Creates it on first access using the current Clerk instance - Returns the result of calling the cached function with provided options The method signature matches the imported types and follows the experimental naming convention used throughout the codebase. </details> <details> <summary>packages/shared/src/error.ts (1)</summary> `1-5`: **Good type safety improvement!** Implementing the `ClerkAPIResponseErrorInterface` ensures type consistency across the codebase and aligns with the interface defined in `@clerk/types`. Also applies to: 162-162 </details> <details> <summary>packages/clerk-js/src/ui/components/Checkout/parts.tsx (2)</summary> `1-1`: **Correctly migrated to the new useCheckout hook.** The error handling has been properly updated to use the new hook's error structure with appropriate null checking. Also applies to: 14-15, 33-33 --- `41-47`: **Well-structured separation of concerns.** The component correctly uses `useCheckoutContext` for configuration data and `useCheckout` for state/error data. </details> <details> <summary>packages/shared/src/react/hooks/useCheckout.ts (1)</summary> `16-43`: **Well-designed type utilities and definitions.** The utility types `RemoveFunctions` and `Nullable` provide clean type transformations, and the checkout property types ensure proper type safety. </details> <details> <summary>packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx (2)</summary> `34-40`: **Clean conditional rendering implementation.** The Stage component provides a clear and simple way to conditionally render content based on checkout status. --- `42-71`: **Well-structured error state handling.** The FetchStatus component properly extracts and handles specific error codes, providing granular control over error UI rendering. </details> <details> <summary>packages/clerk-js/src/core/modules/checkout/instance.ts (2)</summary> `12-18`: **Good cache key generation strategy.** The cacheKey function creates unique identifiers by combining user ID, organization ID (or 'user'), plan ID, and plan period, ensuring proper cache isolation. --- `23-85`: **Excellent checkout instance implementation.** The implementation features: - Proper authentication validation - Clear error messages for missing prerequisites - Well-structured async operations with the manager pattern - Clean separation of concerns between instance methods and manager operations </details> <details> <summary>packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts (1)</summary> `56-634`: **Well-structured and comprehensive test coverage!** The test suite provides excellent coverage of the checkout manager functionality, including: - State management and immutability - Subscription mechanics - Concurrent operation handling and deduplication - Error propagation - Cache isolation between different checkout keys The test organization with clear describe blocks and descriptive test names makes it easy to understand the expected behavior. </details> <details> <summary>packages/types/src/clerk.ts (2)</summary> `61-88`: **Well-designed experimental checkout types!** The type definitions follow TypeScript best practices: - Proper use of `readonly` for immutable state properties - Clear type unions for status values - Consistent experimental naming convention - Comprehensive interface for checkout operations The types provide a solid foundation for the checkout feature implementation. --- `815-821`: **Appropriate addition of experimental checkout API to Clerk interface.** The addition follows the established pattern for experimental features in the codebase, using the `__experimental_` prefix to clearly indicate its experimental status. </details> <details> <summary>packages/clerk-js/src/core/modules/checkout/manager.ts (3)</summary> `3-27`: **Excellent use of branded types and cache initialization patterns!** The implementation demonstrates strong TypeScript practices: - Branded type `CheckoutKey` prevents accidental string usage - Generic cache factory provides type-safe storage - Helper methods ensure Maps are properly initialized before access --- `46-76`: **Clean state derivation implementation with proper immutability!** The state derivation logic is well-structured: - Clear separation between base state and derived properties - Immutable default state using `Object.freeze` - Readable conditional logic using IIFE pattern --- `89-178`: **Well-architected checkout manager with clean API design!** The manager implementation demonstrates excellent software engineering practices: - Clear separation of concerns - Proper encapsulation of internal state - Intuitive public API with subscribe, executeOperation, and clearCheckout methods - Comprehensive JSDoc documentation </details> <details> <summary>packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (3)</summary> `1-1`: **Clean migration to experimental checkout hook!** The migration from `useCheckoutContextRoot` to `__experimental_useCheckout` is well-executed: - Clear import with appropriate aliasing - Proper destructuring of the new API surface - Maintains existing null safety checks - Correctly passes internal checkout object to child components Also applies to: 31-38, 116-116 --- `121-178`: **Excellent simplification of checkout mutations!** The refactored `useCheckoutMutations` hook benefits from the new checkout API: - Direct use of `confirm` method eliminates manual state management - Cleaner error handling flow - Significant simplification of `payWithTestCard` function - Maintains proper organization context injection This demonstrates how the new API improves developer experience. --- `283-310`: **Consistent adaptation to new checkout API structure.** The `AddPaymentSourceForCheckout` component correctly adapts to the new API: - Proper destructuring of checkout state - Maintains null safety with id check - Clean access to totals data - Correctly passes internal checkout to child components </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
/** | ||
* | ||
*/ |
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.
🛠️ Refactor suggestion
Complete or remove empty JSDoc comments.
The empty JSDoc comment blocks don't provide any documentation value. According to the coding guidelines, comprehensive JSDoc comments should be maintained for public APIs.
Complete these JSDoc comments with proper documentation:
-/**
- *
- */
+/**
+ * Checks if the provided error is an unauthorized error (401 with authentication_invalid code).
+ * @param e - The error object to check
+ * @returns True if the error is an unauthorized error, false otherwise
+ */
export function isUnauthorizedError(e: any): boolean {
Apply similar documentation to all other functions with empty JSDoc blocks.
Also applies to: 17-19, 24-26, 32-34, 56-58, 63-65, 89-91, 97-99, 104-106, 111-113, 118-120, 124-126, 143-145, 259-261, 320-323, 331-334
🤖 Prompt for AI Agents
In packages/shared/src/error.ts at lines 7 to 9 and similarly at the other
specified line ranges, there are empty JSDoc comment blocks that should either
be removed or completed. Review each empty JSDoc block and add meaningful
documentation describing the function's purpose, parameters, return values, and
any relevant details according to the coding guidelines. If documentation is not
needed, remove the empty comment block entirely to maintain code clarity.
@@ -92,7 +92,7 @@ export const InvalidPlanScreen = () => { | |||
}; | |||
|
|||
export const AddEmailForm = () => { | |||
const { startCheckout } = useCheckoutContextRoot(); | |||
const { start } = useCheckout(); |
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.
Avoid silently suppressing errors.
The .catch(() => null)
pattern suppresses errors without handling them properly. This could hide important failures from users.
Consider proper error handling:
- onSuccess={() => start().catch(() => null)}
+ onSuccess={async () => {
+ try {
+ await start();
+ } catch (error) {
+ // Log error or show user feedback
+ console.error('Failed to start checkout:', error);
+ }
+ }}
Also applies to: 108-108
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/components/Checkout/parts.tsx at lines 95 and 108,
the current use of .catch(() => null) suppresses errors silently. Replace this
pattern with proper error handling by either logging the error, showing a
user-friendly message, or implementing retry logic to ensure failures are not
hidden and can be addressed appropriately.
// @ts-expect-error - this is a temporary fix to allow the checkout to be null | ||
checkout: null, | ||
// @ts-expect-error - this is a temporary fix to allow the checkout to be null | ||
__internal_checkout: managerProperties.checkout, |
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.
Fix type errors instead of suppressing them.
The @ts-expect-error
comments indicate type mismatches that should be resolved properly. Suppressing TypeScript errors can lead to runtime issues.
The comments mention these are "temporary fixes" - please address the underlying type issues to ensure type safety.
🤖 Prompt for AI Agents
In packages/shared/src/react/hooks/useCheckout.ts around lines 119 to 122, the
use of @ts-expect-error to suppress type errors for the checkout and
__internal_checkout properties indicates unresolved type mismatches. To fix
this, update the type definitions or interfaces involved to correctly allow
these properties to be null or the expected types, removing the need for error
suppression comments. Ensure the types align with the actual values assigned to
maintain type safety and prevent runtime issues.
const Initiator = () => { | ||
const checkout = useCheckout(); | ||
|
||
useEffect(() => { | ||
void startCheckout(); | ||
return () => { | ||
// Clear the cache on unmount | ||
mutate(undefined, false); | ||
}; | ||
checkout.start().catch(() => null); | ||
return checkout.clear; | ||
}, []); | ||
|
||
return { | ||
checkout: data, | ||
startCheckout, | ||
updateCheckout: (checkout: CommerceCheckoutResource) => { | ||
void mutate(checkout, false); | ||
onSubscriptionComplete?.(); | ||
}, | ||
isMutating, | ||
errors: error?.errors, | ||
}; | ||
return null; | ||
}; |
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.
Handle checkout start errors properly.
Silently suppressing errors with .catch(() => null)
hides failures from users and makes debugging difficult.
useEffect(() => {
- checkout.start().catch(() => null);
+ checkout.start().catch((error) => {
+ console.error('Failed to start checkout:', error);
+ // Consider showing user feedback or retrying
+ });
return checkout.clear;
}, []);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const Initiator = () => { | |
const checkout = useCheckout(); | |
useEffect(() => { | |
void startCheckout(); | |
return () => { | |
// Clear the cache on unmount | |
mutate(undefined, false); | |
}; | |
checkout.start().catch(() => null); | |
return checkout.clear; | |
}, []); | |
return { | |
checkout: data, | |
startCheckout, | |
updateCheckout: (checkout: CommerceCheckoutResource) => { | |
void mutate(checkout, false); | |
onSubscriptionComplete?.(); | |
}, | |
isMutating, | |
errors: error?.errors, | |
}; | |
return null; | |
}; | |
const Initiator = () => { | |
const checkout = useCheckout(); | |
useEffect(() => { | |
checkout.start().catch((error) => { | |
console.error('Failed to start checkout:', error); | |
// Consider showing user feedback or retrying | |
}); | |
return checkout.clear; | |
}, []); | |
return null; | |
}; |
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx around lines 9
to 17, the current code suppresses errors from checkout.start() by catching them
and returning null, which hides failures. Modify the error handling to properly
catch and log or handle errors instead of ignoring them, so that failures are
visible and can be debugged or communicated to the user.
const Root = ({ children }: { children: React.ReactNode }) => { | ||
const { checkout, isMutating, updateCheckout, errors, startCheckout } = useCheckoutCreator(); | ||
|
||
const status = useMemo(() => { | ||
if (isMutating) return 'pending'; | ||
const completedCode = 'completed'; | ||
if (checkout?.status === completedCode) return completedCode; | ||
if (checkout) return 'ready'; | ||
|
||
const missingCode = 'missing_payer_email'; | ||
const isMissingPayerEmail = !!errors?.some((e: ClerkAPIError) => e.code === missingCode); | ||
if (isMissingPayerEmail) return missingCode; | ||
const invalidChangeCode = 'invalid_plan_change'; | ||
if (errors?.[0]?.code === invalidChangeCode) return invalidChangeCode; | ||
return 'error'; | ||
}, [isMutating, errors, checkout, checkout?.status]); | ||
const { planId, planPeriod, subscriberType } = useCheckoutContext(); | ||
|
||
return ( | ||
<CheckoutContextRoot.Provider | ||
value={{ | ||
checkout, | ||
isLoading: isMutating, | ||
updateCheckout, | ||
errors, | ||
startCheckout, | ||
status, | ||
}} | ||
<CheckoutProvider | ||
for={subscriberType === 'org' ? 'organization' : undefined} | ||
planId={planId!} | ||
planPeriod={planPeriod!} | ||
> | ||
<Initiator /> | ||
{children} | ||
</CheckoutContextRoot.Provider> | ||
</CheckoutProvider> | ||
); | ||
}; |
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.
Validate required props instead of using non-null assertions.
The non-null assertions on planId!
and planPeriod!
bypass TypeScript's null checking and could cause runtime errors if these values are actually null/undefined.
const Root = ({ children }: { children: React.ReactNode }) => {
const { planId, planPeriod, subscriberType } = useCheckoutContext();
+ if (!planId || !planPeriod) {
+ // Return error state or loading indicator
+ return <div>Missing required checkout configuration</div>;
+ }
+
return (
<CheckoutProvider
for={subscriberType === 'org' ? 'organization' : undefined}
- planId={planId!}
- planPeriod={planPeriod!}
+ planId={planId}
+ planPeriod={planPeriod}
>
<Initiator />
{children}
</CheckoutProvider>
);
};
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const Root = ({ children }: { children: React.ReactNode }) => { | |
const { checkout, isMutating, updateCheckout, errors, startCheckout } = useCheckoutCreator(); | |
const status = useMemo(() => { | |
if (isMutating) return 'pending'; | |
const completedCode = 'completed'; | |
if (checkout?.status === completedCode) return completedCode; | |
if (checkout) return 'ready'; | |
const missingCode = 'missing_payer_email'; | |
const isMissingPayerEmail = !!errors?.some((e: ClerkAPIError) => e.code === missingCode); | |
if (isMissingPayerEmail) return missingCode; | |
const invalidChangeCode = 'invalid_plan_change'; | |
if (errors?.[0]?.code === invalidChangeCode) return invalidChangeCode; | |
return 'error'; | |
}, [isMutating, errors, checkout, checkout?.status]); | |
const { planId, planPeriod, subscriberType } = useCheckoutContext(); | |
return ( | |
<CheckoutContextRoot.Provider | |
value={{ | |
checkout, | |
isLoading: isMutating, | |
updateCheckout, | |
errors, | |
startCheckout, | |
status, | |
}} | |
<CheckoutProvider | |
for={subscriberType === 'org' ? 'organization' : undefined} | |
planId={planId!} | |
planPeriod={planPeriod!} | |
> | |
<Initiator /> | |
{children} | |
</CheckoutContextRoot.Provider> | |
</CheckoutProvider> | |
); | |
}; | |
const Root = ({ children }: { children: React.ReactNode }) => { | |
const { planId, planPeriod, subscriberType } = useCheckoutContext(); | |
if (!planId || !planPeriod) { | |
// Return error state or loading indicator | |
return <div>Missing required checkout configuration</div>; | |
} | |
return ( | |
<CheckoutProvider | |
for={subscriberType === 'org' ? 'organization' : undefined} | |
planId={planId} | |
planPeriod={planPeriod} | |
> | |
<Initiator /> | |
{children} | |
</CheckoutProvider> | |
); | |
}; |
🧰 Tools
🪛 ESLint
[error] 25-25: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
[error] 26-26: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx around lines 19
to 32, the code uses non-null assertions on planId and planPeriod which can lead
to runtime errors if these values are null or undefined. Replace the non-null
assertions by adding proper validation checks for planId and planPeriod before
rendering CheckoutProvider, and handle the case when they are missing, such as
returning null or an error message, to ensure safe usage.
expect(state.isStarting).toBe(true); | ||
expect(state.fetchStatus).toBe('fetching'); | ||
|
||
// Resolve the operation | ||
resolveOperation!(mockCheckout); | ||
await operationPromise; |
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.
Replace non-null assertion with proper type narrowing.
The non-null assertion operator !
is discouraged. Consider using proper type narrowing instead to ensure type safety.
- // Resolve the operation
- resolveOperation!(mockCheckout);
- await operationPromise;
+ // Resolve the operation
+ if (resolveOperation) {
+ resolveOperation(mockCheckout);
+ }
+ await operationPromise;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
expect(state.isStarting).toBe(true); | |
expect(state.fetchStatus).toBe('fetching'); | |
// Resolve the operation | |
resolveOperation!(mockCheckout); | |
await operationPromise; | |
expect(state.isStarting).toBe(true); | |
expect(state.fetchStatus).toBe('fetching'); | |
// Resolve the operation | |
if (resolveOperation) { | |
resolveOperation(mockCheckout); | |
} | |
await operationPromise; |
🧰 Tools
🪛 ESLint
[error] 460-460: Forbidden non-null assertion.
(@typescript-eslint/no-non-null-assertion)
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts around
lines 456 to 461, replace the non-null assertion operator `!` used on
`resolveOperation` with proper type narrowing. Add a conditional check to verify
that `resolveOperation` is defined before calling it, ensuring type safety
without using the non-null assertion.
return manager.executeOperation('confirm', async () => { | ||
const checkout = manager.getCacheState().checkout; | ||
if (!checkout) { | ||
throw new Error('Clerk: Call `start` before `confirm`'); |
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.
Make this a ClerkRuntimeError
Description
React
Usage without provider
Usage with provider
Vanilla JS
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Refactor
Documentation
Tests