Skip to content

Introduce useCheckout #6195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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