Skip to content

chore(clerk-js, shared): Expose useCheckout as experimental #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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
55e340c
chore(clerk-js, shared): Expose `useCheckout` as experimental
panteliselef Jun 24, 2025
f000508
wip nested useCheckout
panteliselef Jun 24, 2025
1689aac
wip singleton checkout
panteliselef Jun 24, 2025
a1cea14
remove singleton
panteliselef Jun 25, 2025
f46e630
flatten properties
panteliselef Jun 25, 2025
ffbbd05
remove duplicate code from mutation methods
panteliselef Jun 25, 2025
6d6d527
wip
panteliselef Jun 25, 2025
87d3e6a
derive state in manager
panteliselef Jun 25, 2025
752a244
introduce CheckoutProvider
panteliselef Jun 25, 2025
24a22f0
refactor subscribe of useSyncExternalStore
panteliselef Jun 25, 2025
f3e2c79
create vanilla js api
panteliselef Jun 26, 2025
17e54ed
export useCheckout to nextjs
panteliselef Jun 26, 2025
2e1a850
fix isomorphicClerk.ts
panteliselef Jun 26, 2025
e1ed2c7
track inflight requests
panteliselef Jun 26, 2025
ba5f4bc
Merge branch 'refs/heads/main' into elef/com-960-useCheckout
panteliselef Jun 27, 2025
6b275b5
expose `getState()` from useCheckout
panteliselef Jun 27, 2025
f563d05
mark checkout as experimental and cleanup
panteliselef Jun 27, 2025
078e5db
add unit tests for manager
panteliselef Jun 27, 2025
61fe81d
experimental provider
panteliselef Jun 27, 2025
ec9ea1c
introduce `ClerkAPIResponseError` in @clerk/types
panteliselef Jun 27, 2025
907d149
handle public types
panteliselef Jun 27, 2025
33e17b3
Merge branch 'main' into elef/com-960-useCheckout
panteliselef Jun 27, 2025
f501d70
update snapshot
panteliselef Jun 27, 2025
79972b2
Merge branch 'refs/heads/main' into elef/com-960-useCheckout
panteliselef Jul 4, 2025
9a16e29
update snapshots
panteliselef Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/stale-pillows-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@clerk/clerk-js': minor
'@clerk/nextjs': minor
'@clerk/shared': minor
'@clerk/clerk-react': minor
'@clerk/types': minor
---

wip
Copy link
Member Author

Choose a reason for hiding this comment

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

I will update this :)

11 changes: 11 additions & 0 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { addClerkPrefix, isAbsoluteUrl, stripScheme } from '@clerk/shared/url';
import { allSettled, handleValueOrFn, noop } from '@clerk/shared/utils';
import type {
__experimental_CheckoutInstance,
__experimental_CheckoutOptions,
__internal_CheckoutProps,
__internal_ComponentNavigationContext,
__internal_OAuthConsentProps,
Expand Down Expand Up @@ -136,6 +138,7 @@ import type { FapiClient, FapiRequestCallback } from './fapiClient';
import { createFapiClient } from './fapiClient';
import { createClientFromJwt } from './jwt-client';
import { APIKeys } from './modules/apiKeys';
import { createCheckoutInstance } from './modules/checkout/instance';
import { CommerceBilling } from './modules/commerce';
import {
BaseResource,
Expand Down Expand Up @@ -195,6 +198,7 @@ export class Clerk implements ClerkInterface {
};
private static _billing: CommerceBillingNamespace;
private static _apiKeys: APIKeysNamespace;
private _checkout: ClerkInterface['__experimental_checkout'] | undefined;

public client: ClientResource | undefined;
public session: SignedInSessionResource | null | undefined;
Expand Down Expand Up @@ -337,6 +341,13 @@ export class Clerk implements ClerkInterface {
return Clerk._apiKeys;
}

__experimental_checkout(options: __experimental_CheckoutOptions): __experimental_CheckoutInstance {
if (!this._checkout) {
this._checkout = params => createCheckoutInstance(this, params);
}
return this._checkout(options);
}

public __internal_getOption<K extends keyof ClerkOptions>(key: K): ClerkOptions[K] {
return this.#options[key];
}
Expand Down
Loading
Loading