Skip to content

Commit f6a1c35

Browse files
authored
chore(clerk-js, shared): Expose useCheckout as experimental (#6195)
1 parent 2be6a53 commit f6a1c35

File tree

35 files changed

+1611
-228
lines changed

35 files changed

+1611
-228
lines changed

.changeset/every-buttons-travel.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@clerk/tanstack-react-start': minor
3+
'@clerk/react-router': minor
4+
'@clerk/nextjs': minor
5+
'@clerk/shared': minor
6+
'@clerk/clerk-react': minor
7+
'@clerk/remix': minor
8+
---
9+
10+
[Billing Beta]: Introduce experimental `useCheckout()` hook and `<CheckoutProvider/>`.

.changeset/great-roses-punch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/clerk-react': minor
4+
'@clerk/types': minor
5+
---
6+
7+
[Billing Beta]: Introduce experimental `Clerk.__experimental_checkout()` for managing the state of a checkout session.

.changeset/stale-pillows-sneeze.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/nextjs': minor
4+
'@clerk/shared': minor
5+
'@clerk/clerk-react': minor
6+
'@clerk/types': minor
7+
---
8+
9+
wip

packages/clerk-js/bundlewatch.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"files": [
3-
{ "path": "./dist/clerk.js", "maxSize": "612kB" },
3+
{ "path": "./dist/clerk.js", "maxSize": "612.37kB" },
44
{ "path": "./dist/clerk.browser.js", "maxSize": "72.2KB" },
55
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "115KB" },
66
{ "path": "./dist/clerk.headless*.js", "maxSize": "55KB" },
7-
{ "path": "./dist/ui-common*.js", "maxSize": "111.9KB" },
8-
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "113.67KB" },
7+
{ "path": "./dist/ui-common*.js", "maxSize": "110KB" },
8+
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "113.72KB" },
99
{ "path": "./dist/vendors*.js", "maxSize": "40.2KB" },
1010
{ "path": "./dist/coinbase*.js", "maxSize": "38KB" },
1111
{ "path": "./dist/stripe-vendors*.js", "maxSize": "1KB" },

packages/clerk-js/src/core/clerk.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
import { addClerkPrefix, isAbsoluteUrl, stripScheme } from '@clerk/shared/url';
1616
import { allSettled, handleValueOrFn, noop } from '@clerk/shared/utils';
1717
import type {
18+
__experimental_CheckoutInstance,
19+
__experimental_CheckoutOptions,
1820
__internal_CheckoutProps,
1921
__internal_ComponentNavigationContext,
2022
__internal_OAuthConsentProps,
@@ -137,6 +139,7 @@ import type { FapiClient, FapiRequestCallback } from './fapiClient';
137139
import { createFapiClient } from './fapiClient';
138140
import { createClientFromJwt } from './jwt-client';
139141
import { APIKeys } from './modules/apiKeys';
142+
import { createCheckoutInstance } from './modules/checkout/instance';
140143
import { CommerceBilling } from './modules/commerce';
141144
import {
142145
BaseResource,
@@ -197,6 +200,7 @@ export class Clerk implements ClerkInterface {
197200
};
198201
private static _billing: CommerceBillingNamespace;
199202
private static _apiKeys: APIKeysNamespace;
203+
private _checkout: ClerkInterface['__experimental_checkout'] | undefined;
200204

201205
public client: ClientResource | undefined;
202206
public session: SignedInSessionResource | null | undefined;
@@ -339,6 +343,13 @@ export class Clerk implements ClerkInterface {
339343
return Clerk._apiKeys;
340344
}
341345

346+
__experimental_checkout(options: __experimental_CheckoutOptions): __experimental_CheckoutInstance {
347+
if (!this._checkout) {
348+
this._checkout = params => createCheckoutInstance(this, params);
349+
}
350+
return this._checkout(options);
351+
}
352+
342353
public __internal_getOption<K extends keyof ClerkOptions>(key: K): ClerkOptions[K] {
343354
return this.#options[key];
344355
}

0 commit comments

Comments
 (0)