Skip to content

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Jun 23, 2025

Description

Exposing the following Components and hooks as experimental.

  • PaymentElementProvider
  • PaymentElement
  • usePaymentElement

Example usage:

<PaymentElementProvider>

  <PaymentElement />
  <MyButtonSubmit />

</PaymentElementProvider>

function MyButtonSubmit(){
  const { submit } = usePaymentElement()
  
  const onClick = async () => {
    const { data, error } = await submit()
    // Use `data` to confirm a checkout, or add a register a new payment method
  }
  return <button onClick={onClick}>Submit</button> 
}

Checklist

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

Type of change

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

Summary by CodeRabbit

  • New Features

    • Introduced experimental payment element components and hooks, enabling integration of Stripe payment UI elements within Clerk-powered applications.
    • Added internal methods to load Stripe.js libraries for improved payment processing support.
    • Provided new React components and hooks for managing Stripe Elements in payment flows.
  • Refactor

    • Replaced direct Stripe SDK integration with new experimental abstractions, simplifying payment source management and UI logic.
    • Centralized and streamlined payment confirmation and source addition flows.
  • Chores

    • Updated and removed Stripe-related dependencies to optimize package management.
    • Adjusted bundle size configurations for improved monitoring and maintenance.
  • Documentation

    • Improved internal documentation and comments for clarity.

Copy link

changeset-bot bot commented Jun 23, 2025

🦋 Changeset detected

Latest commit: 02d3552

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

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

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

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

Copy link

vercel bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2025 11:11am

Copy link

pkg-pr-new bot commented Jun 23, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6180

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6180

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6180

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6180

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6180

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6180

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6180

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6180

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6180

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6180

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6180

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6180

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6180

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6180

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6180

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6180

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6180

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6180

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6180

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6180

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6180

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6180

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6180

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6180

commit: 02d3552

Copy link
Contributor

coderabbitai bot commented Jun 23, 2025

📝 Walkthrough

Walkthrough

This change introduces a new experimental payment element integration throughout the Clerk ecosystem, centered on Stripe payment flows. It adds an internal asynchronous method __internal_loadStripeJs to the Clerk interface and related classes for controlled Stripe.js loading. The direct dependency on @stripe/react-stripe-js is removed from the @clerk/clerk-js package, replaced by a custom React Stripe integration in shared packages. This integration provides new hooks and components (__experimental_usePaymentElement, __experimental_PaymentElementProvider, and __experimental_PaymentElement) to manage Stripe Elements lifecycle, UI rendering, and payment submission. Payment source and checkout components are refactored to use these abstractions, simplifying Stripe SDK usage and consolidating organization ID handling. Bundle size watch limits and chunking configurations are adjusted to reflect new chunking strategies. Experimental payment utilities are exported across multiple packages, and supporting utilities for Stripe Elements event handling and context management are implemented.

Suggested reviewers

  • tmilewski
  • wobsoriano

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2c595 and 02d3552.

📒 Files selected for processing (1)
  • packages/shared/src/react/commerce.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/shared/src/react/commerce.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

coderabbitai bot commented Jun 23, 2025

📝 Walkthrough

Walkthrough

This change set introduces Stripe payment element integration and related infrastructure updates across several packages. It adds a new internal method, __internal_loadStripeLibs, to the Clerk interface and its implementations, enabling dynamic loading of Stripe libraries. The bundle configuration is updated to isolate Stripe dependencies into a dedicated chunk, and related size limits are adjusted. In the UI, payment source components are refactored to use new experimental payment element components and hooks from @clerk/shared/react, replacing direct Stripe SDK usage and manual payment intent management. New Stripe dependencies are added to development dependencies, and related exports are updated. Documentation comments are also improved in several files.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🔭 Outside diff range comments (1)
.changeset/twelve-yaks-love.md (1)

1-9: Finalize the changeset details before merging

The changeset is marked as wip and lacks a summary of changes/releases. Please update the description, remove wip, and provide context for the minor bumps to @clerk/clerk-js, @clerk/shared, @clerk/clerk-react, and @clerk/types to ensure proper changelog generation.

🧹 Nitpick comments (4)
packages/shared/package.json (1)

153-154: Review dependency categorization and version ranges for Stripe libraries

  1. Stripe libs are runtime dependencies; consider moving them from devDependencies to peerDependencies (or dependencies) so they’re installed by consumers.
  2. Exact pins ("5.6.0", "3.1.1") block minor/patch upgrades—using caret ranges (^5.6.0, ^3.1.1) could provide future fixes.
packages/shared/src/react/hooks/usePagesOrInfinite.ts (1)

14-16: Add a meaningful description to the JSDoc block.

The empty JSDoc comment should include a description of what the getDifferentKeys function does.

 /**
- *
+ * Returns keys from obj1 that don't exist in obj2.
  */
packages/clerk-js/rspack.config.js (1)

84-84: Clarify the TODO comment about externals configuration.

The TODO comment questions whether the externals configuration is still needed. Since you're introducing dynamic Stripe library loading, consider whether this external exclusion is still necessary or if it conflicts with the new dynamic loading approach.

packages/shared/src/react/commerce.tsx (1)

92-96: Clarify the commented build flag check

The commented code suggests uncertainty about environment support. This should be resolved before the experimental feature is used more widely.

Should this check be enabled? If so, what's the proper way to handle unsupported environments? Would you like help implementing proper environment validation?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 877bc85 and cc91f08.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .changeset/twelve-yaks-love.md (1 hunks)
  • packages/clerk-js/bundlewatch.config.json (2 hunks)
  • packages/clerk-js/rspack.config.js (3 hunks)
  • packages/clerk-js/src/core/clerk.ts (1 hunks)
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx (5 hunks)
  • packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx (1 hunks)
  • packages/react/src/isomorphicClerk.ts (1 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/shared/src/getEnvVariable.ts (1 hunks)
  • packages/shared/src/react/commerce.tsx (1 hunks)
  • packages/shared/src/react/hooks/usePagesOrInfinite.ts (3 hunks)
  • packages/shared/src/react/index.ts (1 hunks)
  • packages/types/src/clerk.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
packages/shared/src/react/index.ts (1)

19-19: Re-export of commerce module

This correctly exposes the new experimental Stripe integration hooks and components. Please confirm that all newly exported symbols are covered by unit tests and documented in the public API docs.

packages/clerk-js/bundlewatch.config.json (2)

10-10: Verify new Stripe vendor chunk pattern and size limit

Ensure that the stripe-vendors*.js outputted by rspack.config.js matches this glob and that the 5.54KB threshold reflects real bundle sizes.


25-25: Adjust checkout bundle size threshold

The checkout*.js max size was increased from 7.25KB to 8.30KB. Confirm this change aligns with the measured bundle size post-integration to avoid unintentional size bloat.

packages/shared/src/getEnvVariable.ts (1)

11-17: Consistent JSDoc formatting

Added blank line after the summary and punctuation to parameter/return descriptions improves readability.

packages/types/src/clerk.ts (1)

497-504: LGTM! Good addition for experimental Stripe integration.

The new __internal_loadStripeLibs method follows established patterns for internal methods and is properly documented. The method signature is appropriate for the experimental PaymentElement feature.

Consider improving type safety by replacing Promise<any> with more specific return types if the Stripe library types are available, though any may be acceptable for experimental features.

packages/react/src/isomorphicClerk.ts (1)

1313-1316: LGTM! Implementation follows established patterns.

The __internal_loadStripeLibs method implementation correctly follows the same pattern as other async methods in the class, properly waiting for ClerkJS to be ready before delegating to the underlying instance.

packages/shared/src/react/hooks/usePagesOrInfinite.ts (1)

67-67: Good documentation improvements.

The addition of periods to JSDoc descriptions improves consistency and readability throughout the file.

Also applies to: 71-71, 75-75, 183-183

packages/clerk-js/rspack.config.js (2)

104-108: Good separation of Stripe dependencies into dedicated chunk.

The new stripeVendor cache group properly isolates Stripe libraries (@stripe/stripe-js and @stripe/react-stripe-js) into a separate stripe-vendors chunk. This aligns well with the dynamic loading strategy and supports optimal code splitting.


117-121: Appropriate removal of legacy paymentSources cache group.

Commenting out the paymentSources cache group makes sense since Stripe libraries are now handled by the dedicated stripeVendor cache group. This prevents double-bundling and maintains cleaner chunk separation.

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

27-29: Clean refactor of the payment source callback

The simplified callback signature with direct context passing improves code clarity and aligns well with the new Stripe integration approach.

packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)

148-159: Good simplification of payment confirmation functions

The removal of redundant async/await and the consolidated context handling make the code cleaner and more maintainable. The new signature with explicit gateway and paymentToken properties is also more type-safe.

packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx (1)

204-220: ```shell
#!/bin/bash

Locate the definition and usages of submitPaymentElement in the codebase

rg "submitPaymentElement" -n -A5 -B5


</details>
<details>
<summary>packages/shared/src/react/commerce.tsx (2)</summary>

`1-335`: **Well-architected Stripe integration layer**

This implementation provides a clean abstraction over Stripe's SDKs with good separation of concerns:
- Async loading of Stripe libraries
- Proper caching with SWR
- Clear context boundaries
- Reusable hooks

Once the identified issues are addressed, this will be a solid foundation for the payment element feature.

---

`298-304`: [web_search]
```web
Is confirmParams.return_url required for stripe.confirmSetup when using redirect: 'if_required' in Stripe.js v3?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (7)
packages/shared/src/react/hooks/usePagesOrInfinite.ts (1)

14-16: Empty JSDoc block
This JSDoc block above getDifferentKeys is empty. Either provide a meaningful description or remove the block to keep the code clean.

packages/types/src/clerk.ts (1)

497-504: LGTM! Well-documented internal API declaration.

The type declaration is properly documented and structured. The return type with separate javascript() and react() functions provides a clean interface for loading different Stripe libraries.

Consider using more specific return types instead of Promise<any> if the loaded library types are known, but the current approach provides flexibility for dynamic imports.

packages/clerk-js/src/core/clerk.ts (1)

648-659: Consider improving return types and adding error handling.

The implementation looks good overall, but there are a few areas for improvement:

  1. Return types: Using unknown makes it difficult for consumers to understand what they're getting. Consider using more specific return types.
  2. Error handling: The dynamic imports could fail if packages aren't installed. Consider adding error handling or documenting that callers should handle import failures.
  public __internal_loadStripeLibs = () => {
    return {
-      async javascript(): Promise<unknown> {
+      async javascript(): Promise<typeof import('@stripe/stripe-js')['loadStripe']> {
        const { loadStripe } = await import('@stripe/stripe-js');
        return loadStripe;
      },
-      async react(): Promise<unknown> {
+      async react(): Promise<{
+        Elements: typeof import('@stripe/react-stripe-js')['Elements'];
+        PaymentElement: typeof import('@stripe/react-stripe-js')['PaymentElement'];
+        useElements: typeof import('@stripe/react-stripe-js')['useElements'];
+        useStripe: typeof import('@stripe/react-stripe-js')['useStripe'];
+      }> {
        const { Elements, PaymentElement, useElements, useStripe } = await import('@stripe/react-stripe-js');
        return { Elements, PaymentElement, useElements, useStripe };
      },
    };
  };
packages/clerk-js/rspack.config.js (1)

117-121: Consider removing commented code if refactoring is complete.

The commented-out paymentSources cache group suggests this configuration is no longer needed. If the refactoring to use the new Stripe vendor chunk is complete, consider removing this commented code to keep the configuration clean.

-          // paymentSources: {
-          //   minChunks: 1,
-          //   name: 'paymentSources',
-          //   test: module => !!(module.resource && module.resource.includes('/ui/components/PaymentSources')),
-          // },
packages/shared/src/react/commerce.tsx (1)

91-106: Consider adding retry logic for Stripe SDK loading.

The Stripe SDK loading could fail due to network issues. Consider implementing retry logic or fallback behavior.

Consider wrapping the Stripe loading with retry logic to handle transient network failures, especially important for payment functionality.

packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx (2)

1-6: Document the experimental nature of these imports.

These imports use __experimental_ prefixed exports, indicating they may change or be removed. Consider adding a comment documenting this dependency on experimental APIs.

+// Note: These are experimental APIs that may change in future versions
 import {
   __experimental_PaymentElementForm as PaymentElementForm,
   __experimental_PaymentElementRoot as PaymentElementRoot,
   __experimental_usePaymentElement as usePaymentElement,
   createContextAndHook,
 } from '@clerk/shared/react';

23-47: Well-structured Stripe appearance configuration.

The useStipeAppearance hook provides a clean abstraction for translating the internal theme to Stripe's appearance variables. The use of normalizeColorString ensures color format compatibility.

Note: There's a typo in the hook name - should be useStripeAppearance instead of useStipeAppearance.

-const useStipeAppearance = () => {
+const useStripeAppearance = () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 877bc85 and cc91f08.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .changeset/twelve-yaks-love.md (1 hunks)
  • packages/clerk-js/bundlewatch.config.json (2 hunks)
  • packages/clerk-js/rspack.config.js (3 hunks)
  • packages/clerk-js/src/core/clerk.ts (1 hunks)
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx (5 hunks)
  • packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx (1 hunks)
  • packages/react/src/isomorphicClerk.ts (1 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/shared/src/getEnvVariable.ts (1 hunks)
  • packages/shared/src/react/commerce.tsx (1 hunks)
  • packages/shared/src/react/hooks/usePagesOrInfinite.ts (3 hunks)
  • packages/shared/src/react/index.ts (1 hunks)
  • packages/types/src/clerk.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (23)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 13)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, 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 (expo-web, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
packages/shared/src/react/hooks/usePagesOrInfinite.ts (3)

67-68: JSDoc punctuation update
Added a period at the end of the parameter description. No issues.


71-72: JSDoc punctuation update
Added a period at the end of the function description. Approved.


183-184: JSDoc punctuation update
Adjusted the helper section comment to include a period. Looks good.

packages/clerk-js/bundlewatch.config.json (2)

10-10: Approve addition of Stripe vendor chunk
The new stripe-vendors*.js entry aligns with the updated Rspack cache group for Stripe dependencies.


25-25: Approve checkout bundle size bump
The increased maxSize for checkout*.js reflects the added PaymentElement code and is expected.

packages/shared/src/getEnvVariable.ts (1)

13-16: JSDoc formatting update
Added trailing periods and an extra blank line for better readability. No functional changes.

packages/shared/src/react/index.ts (1)

19-19: LGTM! Clean module export addition.

The new export statement properly extends the public API to include commerce functionality and follows the established pattern in this file.

packages/react/src/isomorphicClerk.ts (1)

1313-1316: LGTM! Implementation follows established patterns.

The new method correctly follows the async delegation pattern used throughout this class, appropriately waits for ClerkJS to be ready, and maintains consistency with other internal methods.

packages/clerk-js/rspack.config.js (2)

104-108: Good approach to separate Stripe vendor chunking.

The new stripeVendor cache group properly isolates Stripe dependencies into their own chunk, which aligns well with the dynamic loading strategy introduced in the Clerk class.


84-85: ```shell
#!/bin/bash

Display the remainder of rspack.config.js to see how disableRHC is applied

FILE="packages/clerk-js/rspack.config.js"
echo "Lines 110 to end of $FILE:"
sed -n '110,$p' "$FILE"


</details>
<details>
<summary>packages/clerk-js/src/ui/components/PaymentSources/PaymentSources.tsx (1)</summary>

`27-29`: Let’s confirm that `PaymentGateway` includes `"stripe"`:


```shell
#!/bin/bash
# Locate PaymentGateway definition to verify valid values
rg -n "export type PaymentGateway" -A 5 -B 3 packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)

148-159: Consider the error handling implications of removing async/await.

The change from async/await to directly returning promises is functionally equivalent, but it subtly changes error propagation. Errors will now be promise rejections rather than thrown exceptions. This is fine as long as all callers properly handle promise rejections.

The simplified parameter format for addPaymentSourceAndPay aligns well with the new payment token abstraction.

packages/shared/src/react/commerce.tsx (1)

269-282: Verify the management URL for Apple Pay recurring payments.

The TODO comment questions whether homeUrl is the correct management URL. This URL is important for Apple Pay users to manage their subscriptions.

What is the correct managementURL property for Apple Pay recurring payment requests in Stripe?
packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx (1)

204-212: ```shell
#!/bin/bash

List immediate contents of packages/shared to locate the react module

ls packages/shared


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +153 to +154
"@stripe/react-stripe-js": "3.1.1",
"@stripe/stripe-js": "5.6.0",
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 23, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move Stripe packages to peerDependencies
Stripe libraries are required at runtime by the exported React commerce hooks/components. They should be declared under peerDependencies (or dependencies) instead of devDependencies.

--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -152,8 +152,6 @@
   "devDependencies": {
-    "@stripe/react-stripe-js": "3.1.1",
-    "@stripe/stripe-js": "5.6.0",
     "@types/glob-to-regexp": "0.4.4",
     "cross-fetch": "^4.0.0",
     "esbuild": "0.25.0"
@@ -179,6 +177,12 @@
   "publishConfig": {
     "access": "public"
   },
+  "peerDependencies": {
+    "@stripe/react-stripe-js": "3.1.1",
+    "@stripe/stripe-js": "5.6.0"
+  }
 }
📝 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.

Suggested change
"@stripe/react-stripe-js": "3.1.1",
"@stripe/stripe-js": "5.6.0",
"devDependencies": {
"@types/glob-to-regexp": "0.4.4",
"cross-fetch": "^4.0.0",
"esbuild": "0.25.0"
},
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@stripe/react-stripe-js": "3.1.1",
"@stripe/stripe-js": "5.6.0"
}
🤖 Prompt for AI Agents
In packages/shared/package.json around lines 153 to 154, the Stripe packages
"@stripe/react-stripe-js" and "@stripe/stripe-js" are currently listed under
devDependencies but are needed at runtime by exported React commerce
hooks/components. Move these two packages from devDependencies to
peerDependencies to correctly indicate they are required by consumers of the
package at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are used only for their types during dev, does this changes things ?

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for all imports of Stripe packages in the shared package to understand usage patterns
echo "=== Searching for Stripe package imports in packages/shared ==="
rg '@stripe/' packages/shared/src/ -A 2 -B 1

echo -e "\n=== Checking for type-only imports ==="
rg 'import\s+type.*@stripe/' packages/shared/src/

echo -e "\n=== Checking for runtime imports ==="
rg 'import.*@stripe/' packages/shared/src/ | grep -v 'import type'

echo -e "\n=== Checking for actual usage of Stripe objects (not just types) ==="
rg 'useStripe|useElements|Elements|PaymentElement|loadStripe' packages/shared/src/ -A 1 -B 1

Length of output: 19610


@panteliselef You're partially correct! Looking at the code, I can see there are indeed type-only imports like:

import type { StripeElement } from '@stripe/stripe-js';
import type { ElementProps, PaymentElementProps } from '@stripe/react-stripe-js';

However, the situation is more nuanced. While the packages are imported for types during development, the @clerk/shared package exports experimental React components and hooks (__experimental_PaymentElementRoot, __experimental_PaymentElementForm, __experimental_usePaymentElement) that provide a complete Stripe Elements integration.

These exported components implement their own Elements, useElements, useStripe, and PaymentElement - essentially creating a runtime dependency for consumers who use these experimental features.

Even though Stripe libraries are loaded dynamically via clerk.__internal_loadStripeJs(), consumers of your experimental payment components will still need these Stripe packages available in their environment at runtime.

Recommendation: Keep them as peerDependencies with optional: true in peerDependenciesMeta. This approach:

  • Indicates they're needed at runtime for the experimental features
  • Doesn't force installation for consumers who don't use the payment features
  • Provides clear guidance when consumers do use the experimental payment components
"peerDependencies": {
  "@stripe/react-stripe-js": "3.1.1",
  "@stripe/stripe-js": "5.6.0"
},
"peerDependenciesMeta": {
  "@stripe/react-stripe-js": { "optional": true },
  "@stripe/stripe-js": { "optional": true }
}

🧠 Learnings used
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/global.mdc:0-0
Timestamp: 2025-06-23T12:25:34.662Z
Learning: Node.js is required for all development and build tasks in the repository.

Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: The monorepo uses pnpm as the package manager and Turbo for build orchestration, which enables efficient dependency management and caching across multiple packages.

Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/global.mdc:0-0
Timestamp: 2025-06-23T12:25:34.662Z
Learning: The monorepo uses pnpm as the package manager, and all contributors should use pnpm for dependency management and scripts.

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.

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/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#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/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: Environment variables prefixed with CLERK_* and NEXT_PUBLIC_CLERK_* are supported for configuration across different environments.

@panteliselef panteliselef self-assigned this Jun 23, 2025
@@ -21,8 +22,7 @@
{ "path": "./dist/waitlist*.js", "maxSize": "1.5KB" },
{ "path": "./dist/keylessPrompt*.js", "maxSize": "6.5KB" },
{ "path": "./dist/pricingTable*.js", "maxSize": "4.02KB" },
{ "path": "./dist/checkout*.js", "maxSize": "7.25KB" },
{ "path": "./dist/paymentSources*.js", "maxSize": "9.17KB" },
{ "path": "./dist/checkout*.js", "maxSize": "8.30KB" },
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing the chunk for paymentSources, increases the chunk for checkout as some of the code is now in that chunk.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
package.json (2)

36-36: Narrowing E2E_APP_ID reduces billing-flow coverage

Changing
E2E_APP_ID=withBilling.*E2E_APP_ID=withBilling.next.appRouter confines the test:integration:billing script to a single demo app. Any billing examples for other frameworks (e.g. Remix, Vite, Astro) will now be skipped, so regressions in those flows could slip through CI.

If the intent was only to stabilise a flaky target, consider parameterising instead of hard-coding:

-E2E_APP_ID=withBilling.next.appRouter
+# Runs Next.js by default; allow override
+E2E_APP_ID=${E2E_APP_ID:-withBilling.*}

or enumerate multiple IDs with a comma-separated list (withBilling.next.appRouter,withBilling.remix.*, etc.).


46-48: Inconsistent package-manager invocation

Scripts test:integration:nuxt (l 46) and test:integration:react-router (l 48) still call npm run … while every other script uses pnpm. Mixing runners can bypass PNPM-specific features (e.g. workspace linking) and produce divergent lock-file resolution.

- "test:integration:nuxt": "E2E_APP_ID=nuxt.node npm run test:integration:base -- --grep @nuxt",
+ "test:integration:nuxt": "E2E_APP_ID=nuxt.node pnpm test:integration:base --grep @nuxt",

Same adjustment for react-router.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce930d0 and 2005c75.

⛔ Files ignored due to path filters (3)
  • packages/react-router/src/__tests__/__snapshots__/exports.test.ts.snap is excluded by !**/*.snap
  • packages/remix/src/__tests__/__snapshots__/exports.test.ts.snap is excluded by !**/*.snap
  • packages/tanstack-react-start/src/__tests__/__snapshots__/exports.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • packages/chrome-extension/src/index.ts (1 hunks)
  • packages/chrome-extension/src/react/re-exports.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/chrome-extension/src/react/re-exports.ts
🧰 Additional context used
📓 Path-based instructions (5)
`**/*.{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/chrome-extension/src/index.ts
`**/*.{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/chrome-extension/src/index.ts
`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/chrome-extension/src/index.ts
`**/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/chrome-extension/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.
Avoid any type; prefer unknown when type is uncertain, then narrow with type guards.
Use interface for object shapes that might be extended; use type for unions, primitives, and computed types.
Prefer readonly properties for immutable data structures.
Use private for internal implementation details, protected for inheritance, and public 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.
Use as const for literal types and the satisfies 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/chrome-extension/src/index.ts
🧠 Learnings (3)
📓 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: 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: 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#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: 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: 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.
package.json (4)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Unit tests are run with Jest and Vitest, integration tests with Playwright, and component testing with React Testing Library, demonstrating a layered testing strategy.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-23T12:25:30.457Z
Learning: Use Jest for unit testing and React Testing Library for component testing; use Playwright for end-to-end integration tests.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/global.mdc:0-0
Timestamp: 2025-06-23T12:25:34.662Z
Learning: The monorepo uses pnpm as the package manager, and all contributors should use pnpm for dependency management and scripts.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/global.mdc:0-0
Timestamp: 2025-06-23T12:25:34.662Z
Learning: Comprehensive testing is enforced, including unit, integration, and E2E tests, to ensure code quality across supported frameworks and platforms.
packages/chrome-extension/src/index.ts (13)
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.
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/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/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: 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: 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: Use type-only imports (import type { ... }) to optimize performance and avoid unnecessary code inclusion.
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/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/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/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.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/chrome-extension/src/index.ts (1)

1-1: ```bash
#!/bin/bash

Verify the local react/index.ts exports to confirm component overrides

if [ -f "packages/chrome-extension/src/react/index.ts" ]; then
echo "=== packages/chrome-extension/src/react/index.ts ==="
sed -n '1,200p' packages/chrome-extension/src/react/index.ts
else
echo "✗ File not found: packages/chrome-extension/src/react/index.ts"
echo "Searching for index.ts in react directory:"
fd "index.ts" packages/chrome-extension/src/react/
fi


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2005c75 and aee12d0.

📒 Files selected for processing (5)
  • .changeset/eleven-days-sniff.md (1 hunks)
  • .changeset/great-bees-teach.md (1 hunks)
  • .changeset/many-mirrors-vanish.md (1 hunks)
  • integration/tests/pricing-table.test.ts (1 hunks)
  • packages/testing/src/playwright/unstable/page-objects/checkout.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .changeset/great-bees-teach.md
  • .changeset/many-mirrors-vanish.md
🧰 Additional context used
📓 Path-based instructions (6)
`**/*.{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/testing/src/playwright/unstable/page-objects/checkout.ts
  • integration/tests/pricing-table.test.ts
`**/*.{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/testing/src/playwright/unstable/page-objects/checkout.ts
  • integration/tests/pricing-table.test.ts
`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/testing/src/playwright/unstable/page-objects/checkout.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.
Avoid any type; prefer unknown when type is uncertain, then narrow with type guards.
Use interface for object shapes that might be extended; use type for unions, primitives, and computed types.
Prefer readonly properties for immutable data structures.
Use private for internal implementation details, protected for inheritance, and public 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.
Use as const for literal types and the satisfies 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/testing/src/playwright/unstable/page-objects/checkout.ts
  • integration/tests/pricing-table.test.ts
`**/*.{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:

  • integration/tests/pricing-table.test.ts
`integration/**`: Framework integration templates and E2E tests must be placed in the integration/ directory.

integration/**: Framework integration templates and E2E tests must be placed in the integration/ directory.

📄 Source: CodeRabbit Inference Engine (.cursor/rules/global.mdc)

List of files the instruction was applied to:

  • integration/tests/pricing-table.test.ts
🧠 Learnings (3)
📓 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: 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: 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: 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: All packages are published under the @clerk namespace on npm, ensuring consistent naming and discoverability.
.changeset/eleven-days-sniff.md (2)
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.
integration/tests/pricing-table.test.ts (1)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-23T12:25:40.214Z
Learning: Unit tests are run with Jest and Vitest, integration tests with Playwright, and component testing with React Testing Library, demonstrating a layered testing strategy.
⏰ Context from checks skipped due to timeout of 90000ms (24)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 13)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
.changeset/eleven-days-sniff.md (1)

5-5: Verify method name consistency in changeset description.

The changeset description refers to waitForStripeElements but the actual implementation uses waitForStipeElements (missing 'r'). Ensure the method name in the description matches the actual implementation.

#!/bin/bash
# Description: Check the actual method name used in the testing package
# Expected: Should find either waitForStripeElements or waitForStipeElements consistently

echo "Searching for method name in testing package:"
rg "waitFor.*Elements" packages/testing/

…lities

# Conflicts:
#	integration/tests/pricing-table.test.ts
#	packages/testing/src/playwright/unstable/page-objects/checkout.ts
? {
recurringPaymentRequest: {
paymentDescription: paymentDescription || '',
managementURL: environment?.displayConfig.homeUrl || '', // TODO(@COMMERCE): is this the right URL?
Copy link
Member

Choose a reason for hiding this comment

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

❓ do we need a ticket to make sure we find the right value here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No need, this is already address from an already merged PR, now that i've merged from main, it is fixed.

We are now doing

        managementURL:
          subscriberType === 'org'
            ? environment?.displayConfig.organizationProfileUrl || ''
            : environment?.displayConfig.userProfileUrl || '',

…lities

# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/shared/src/react/stripe-react/index.tsx (1)

247-290: Consider using a battle-tested deep equality library.

While the custom isEqual implementation is correct for simple objects, it doesn't handle edge cases like circular references. For production reliability, consider using a well-tested library.

Consider replacing the custom implementation with a proven library:

import isEqual from 'lodash.isequal';

Or if you prefer to keep it lightweight, at least add a check for circular references to prevent potential stack overflow errors in edge cases.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aee12d0 and c69e771.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/clerk-js/bundlewatch.config.json (2 hunks)
  • packages/clerk-js/package.json (0 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/shared/src/react/commerce.tsx (1 hunks)
  • packages/shared/src/react/stripe-react/index.tsx (1 hunks)
  • packages/shared/src/react/stripe-react/utils.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/clerk-js/package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/shared/package.json
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/react/commerce.tsx
🧰 Additional context used
📓 Path-based instructions (8)
`**/*.{js,jsx,ts,tsx}`: All code must pass ESLint checks with the project's conf...

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Use Prettier for consistent code formatting
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Validate all inputs and sanitize outputs
Implement proper logging with different levels

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/utils.ts
  • packages/shared/src/react/stripe-react/index.tsx
`packages/**/*.ts`: TypeScript is required for all packages

packages/**/*.ts: TypeScript is required for all packages

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/utils.ts
`packages/**/*.{ts,tsx,d.ts}`: Packages should export TypeScript types alongside runtime code

packages/**/*.{ts,tsx,d.ts}: Packages should export TypeScript types alongside runtime code

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/utils.ts
  • packages/shared/src/react/stripe-react/index.tsx
`**/*.{ts,tsx}`: Use proper TypeScript error types

**/*.{ts,tsx}: Use proper TypeScript error types

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/utils.ts
  • packages/shared/src/react/stripe-react/index.tsx
`**/*.{ts,tsx}`: Always define explicit return types for functions, especially p...

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document public functions and APIs with JSDoc-style comments including @param, @returns, @throws, and @example
Define custom error classes for domain-specific errors
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining and nullish coalescing for safe property access
Let TypeScript infer types when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use readonly arrays and objects for immutability
Use immutable update patterns (spread, etc.) for objects and arrays
Use lazy loading for large types
Prefer unknown over any for performance
Use type-only imports: import type { ... }
Use branded types for domain safety
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints in TypeScript generics
No unused type parameters in generics
Proper use of utility types instead of manual type construction
Type-only imports where possible for performance
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

📄 Source: CodeRabbit Inference Engine (.cursor/rules/typescript.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/utils.ts
  • packages/shared/src/react/stripe-react/index.tsx
`**/*.{tsx,jsx}`: Use error boundaries in React components Minimize re-renders in React components

**/*.{tsx,jsx}: Use error boundaries in React components
Minimize re-renders in React components

📄 Source: CodeRabbit Inference Engine (.cursor/rules/development.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/index.tsx
`**/*.{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: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper state naming
Use proper handler naming
Implement proper component structure
Use proper hook structure

📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/index.tsx
`**/*.tsx`: Use proper type definitions for props and state Leverage TypeScript'...

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

📄 Source: CodeRabbit Inference Engine (.cursor/rules/react.mdc)

List of files the instruction was applied to:

  • packages/shared/src/react/stripe-react/index.tsx
🧠 Learnings (3)
📓 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-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
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.
packages/shared/src/react/stripe-react/utils.ts (15)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper hook structure
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper state updates with callbacks
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use useState for simple state management
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state selectors
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper event types for handlers
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/*.{ts,tsx} : Proper use of utility types instead of manual type construction
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state persistence
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state naming
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{tsx,jsx} : Minimize re-renders in React components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper refs for DOM access
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper useCallback for handlers
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper cleanup in useEffect
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper event listener cleanup
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper useMemo for expensive computations
packages/shared/src/react/stripe-react/index.tsx (12)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Use proper type definitions for props and state
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper HTML elements
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use proper hook structure
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.test.{jsx,tsx} : Test component interactions
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper component structure
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.tsx : Implement proper generic types for reusable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{tsx,jsx} : Use error boundaries in React components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Use composition over inheritance - prefer smaller, composable components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/react.mdc:0-0
Timestamp: 2025-06-30T10:32:37.848Z
Learning: Applies to **/*.{jsx,tsx} : Implement proper state selectors
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/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Applies to **/*.{tsx,jsx} : Minimize re-renders in React components
🧬 Code Graph Analysis (1)
packages/shared/src/react/stripe-react/index.tsx (2)
packages/shared/src/react/stripe-react/utils.ts (2)
  • usePrevious (4-12)
  • useAttachEvent (14-45)
packages/shared/src/react/commerce.tsx (1)
  • PaymentElement (319-319)
🪛 Biome (1.9.4)
packages/shared/src/react/stripe-react/index.tsx

[error] 218-218: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


[error] 219-219: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/shared/src/react/stripe-react/utils.ts (1)

4-12: LGTM! Standard implementation of the usePrevious hook.

This is a well-established React pattern for tracking previous values. The implementation correctly uses a ref to persist the value across renders and updates it after each render cycle.

packages/shared/src/react/stripe-react/index.tsx (3)

1-10: Great job on proper attribution and licensing!

The file header clearly indicates this is a fork, explains the modifications, and includes the original license information. This is the correct way to handle forked open-source code.


78-148: Excellent implementation of the Elements provider!

The component properly handles:

  • Both synchronous and asynchronous Stripe initialization
  • Race condition prevention with functional setState
  • Memory leak prevention with cleanup and isMounted flag
  • Developer warnings for unsupported prop changes
  • Efficient updates to elements when options change

The implementation follows React best practices and provides a robust foundation for Stripe Elements integration.


327-456: Well-architected factory function for creating Stripe Element components!

The implementation excellently handles:

  • Server-side rendering with a separate ServerElement component
  • Proper lifecycle management with refs and state
  • Synchronous DOM updates with useLayoutEffect
  • Comprehensive event handling using the custom useAttachEvent hook
  • Clean unmounting with proper error handling

The use of refs alongside state ensures elements are immediately available in cleanup hooks, which is crucial for StrictMode compatibility.

@panteliselef panteliselef merged commit ec207dc into main Jul 4, 2025
37 checks passed
@panteliselef panteliselef deleted the elef/com-960-dx-guide-introduce-checkout-utilities branch July 4, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants