import React, { PropsWithChildren, ReactNode } from 'react'; import * as _clerk_types from '@clerk/types'; import { ClerkPaginatedResponse, GetDomainsParams, GetMembershipRequestParams, GetMembersParams, GetInvitationsParams, OrganizationDomainResource, OrganizationMembershipRequestResource, OrganizationMembershipResource, OrganizationInvitationResource, OrganizationResource, GetUserOrganizationMembershipParams, GetUserOrganizationInvitationsParams, GetUserOrganizationSuggestionsParams, UserOrganizationInvitationResource, OrganizationSuggestionResource, CreateOrganizationParams, SetActive, UseSessionReturn, UseSessionListReturn, UseUserReturn, LoadedClerk, SessionVerificationLevel, CommerceStatementResource, CommercePaymentResource, CommercePaymentSourceResource, CommercePlanResource, ForPayerType, ClientResource, ClerkOptions, SignedInSessionResource, UserResource, CommerceSubscriptionPlanPeriod, __experimental_CheckoutCacheState, CommerceCheckoutResource, __experimental_CheckoutInstance, SetActiveNavigate } from '@clerk/types'; import { ClerkAPIResponseError } from '../error.js'; import { dequal } from 'dequal'; /** * Assert that the context value exists, otherwise throw an error. * * @internal */ declare function assertContextExists(contextVal: unknown, msgOrCtx: string | React.Context): asserts contextVal; type Options = { assertCtxFn?: (v: unknown, msg: string) => void; }; type ContextOf = React.Context<{ value: T; } | undefined>; type UseCtxFn = () => T; /** * Create and return a Context and two hooks that return the context value. * The Context type is derived from the type passed in by the user. * * The first hook returned guarantees that the context exists so the returned value is always `CtxValue` * The second hook makes no guarantees, so the returned value can be `CtxValue | undefined` * * @internal */ declare const createContextAndHook: (displayName: string, options?: Options) => [ContextOf, UseCtxFn, UseCtxFn>]; type ValueOrSetter = (size: T | ((_size: T) => T)) => void; type CacheSetter = (data?: CData | ((currentData?: CData) => Promise | undefined | CData)) => Promise; /** * @interface */ type PaginatedResources = { /** * An array that contains the fetched data. For example, for the `memberships` attribute, data will be an array of [`OrganizationMembership`](https://clerk.com/docs/references/javascript/types/organization-membership) objects. */ data: T[]; /** * The total count of data that exist remotely. */ count: number; /** * Clerk's API response error object. */ error: ClerkAPIResponseError | null; /** * A boolean that is `true` if there is an ongoing request and there is no fetched data. */ isLoading: boolean; /** * A boolean that is `true` if there is an ongoing request or a revalidation. */ isFetching: boolean; /** * A boolean that indicates the request failed. */ isError: boolean; /** * The current page. */ page: number; /** * The total amount of pages. It is calculated based on `count`, `initialPage`, and `pageSize`. */ pageCount: number; /** * A function that triggers a specific page to be loaded. */ fetchPage: ValueOrSetter; /** * * A function that triggers the previous page to be loaded. This is the same as `fetchPage(page => Math.max(0, page - 1))`. */ fetchPrevious: () => void; /** * A function that triggers the next page to be loaded. This is the same as `fetchPage(page => Math.min(pageCount, page + 1))`. */ fetchNext: () => void; /** * A boolean that indicates if there are available pages to be fetched. */ hasNextPage: boolean; /** * A boolean that indicates if there are available pages to be fetched. */ hasPreviousPage: boolean; /** * A function that triggers a revalidation of the current page. */ revalidate: () => Promise; /** * A function that allows you to set the data manually. */ setData: Infinite extends true ? CacheSetter<(ClerkPaginatedResponse | undefined)[]> : CacheSetter | undefined>; }; type PaginatedResourcesWithDefault = { [K in keyof PaginatedResources]: PaginatedResources[K] extends boolean ? false : undefined; }; /** * @inline */ type PaginatedHookConfig = T & { /** * If `true`, newly fetched data will be appended to the existing list rather than replacing it. Useful for implementing infinite scroll functionality. * * @default false */ infinite?: boolean; /** * If `true`, the previous data will be kept in the cache until new data is fetched. * * @default false */ keepPreviousData?: boolean; }; /** * @interface */ type PagesOrInfiniteOptions = { /** * A number that specifies which page to fetch. For example, if `initialPage` is set to 10, it will skip the first 9 pages and fetch the 10th page. * * @default 1 */ initialPage?: number; /** * A number that specifies the maximum number of results to return per page. * * @default 10 */ pageSize?: number; /** * @experimental * On `cache` mode, no request will be triggered when the hook is mounted and the data will be fetched from the cache. * * @default undefined * * @hidden */ __experimental_mode?: 'cache'; }; /** * @interface */ type UseOrganizationParams = { /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: *
    *
  • `enrollmentMode`: A string that filters the domains by the provided [enrollment mode](https://clerk.com/docs/organizations/verified-domains#enrollment-mode).
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ domains?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: *
    *
  • `status`: A string that filters the membership requests by the provided status.
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ membershipRequests?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: *
    *
  • `role`: An array of [`OrganizationCustomRoleKey`](https://clerk.com/docs/references/javascript/types/organization-custom-role-key).
  • *
  • `query`: A string that filters the memberships by the provided string.
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ memberships?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: *
    *
  • `status`: A string that filters the invitations by the provided status.
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ invitations?: true | PaginatedHookConfig; }; /** * @interface */ type UseOrganizationReturn = { /** * A boolean that indicates whether Clerk has completed initialization. Initially `false`, becomes `true` once Clerk loads. */ isLoaded: false; /** * The currently active organization. */ organization: undefined; /** * The current organization membership. */ membership: undefined; /** * Includes a paginated list of the organization's domains. */ domains: PaginatedResourcesWithDefault; /** * Includes a paginated list of the organization's membership requests. */ membershipRequests: PaginatedResourcesWithDefault; /** * Includes a paginated list of the organization's memberships. */ memberships: PaginatedResourcesWithDefault; /** * Includes a paginated list of the organization's invitations. */ invitations: PaginatedResourcesWithDefault; } | { isLoaded: true; organization: OrganizationResource; membership: undefined; domains: PaginatedResourcesWithDefault; membershipRequests: PaginatedResourcesWithDefault; memberships: PaginatedResourcesWithDefault; invitations: PaginatedResourcesWithDefault; } | { isLoaded: boolean; organization: OrganizationResource | null; membership: OrganizationMembershipResource | null | undefined; domains: PaginatedResources | null; membershipRequests: PaginatedResources | null; memberships: PaginatedResources | null; invitations: PaginatedResources | null; }; /** * The `useOrganization()` hook retrieves attributes of the currently active organization. * * @example * ### Expand and paginate attributes * * To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. By default, the `memberships`, `invitations`, `membershipRequests`, and `domains` attributes are not populated. You must pass `true` or an object with the desired properties to fetch and paginate the data. * * ```tsx * // invitations.data will never be populated. * const { invitations } = useOrganization() * * // Use default values to fetch invitations, such as initialPage = 1 and pageSize = 10 * const { invitations } = useOrganization({ * invitations: true, * }) * * // Pass your own values to fetch invitations * const { invitations } = useOrganization({ * invitations: { * pageSize: 20, * initialPage: 2, // skips the first page * }, * }) * * // Aggregate pages in order to render an infinite list * const { invitations } = useOrganization({ * invitations: { * infinite: true, * }, * }) * ``` * * @example * ### Infinite pagination * * The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `memberships` attribute will be populated with the first page of the organization's memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list. * * ```tsx * import { useOrganization } from '@clerk/clerk-react' * * export default function MemberList() { * const { memberships } = useOrganization({ * memberships: { * infinite: true, // Append new data to the existing list * keepPreviousData: true, // Persist the cached data until the new data has been fetched * }, * }) * * if (!memberships) { * // Handle loading state * return null * } * * return ( *
*

Organization members

*
    * {memberships.data?.map((membership) => ( *
  • * {membership.publicUserData.firstName} {membership.publicUserData.lastName} < * {membership.publicUserData.identifier}> :: {membership.role} *
  • * ))} *
* * *
* ) * } * ``` * * @example * ### Simple pagination * * The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `memberships` attribute will be populated with the first page of the organization's memberships. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of memberships. * * Notice the difference between this example's pagination and the infinite pagination example above. * * ```tsx * import { useOrganization } from '@clerk/clerk-react' * * export default function MemberList() { * const { memberships } = useOrganization({ * memberships: { * keepPreviousData: true, // Persist the cached data until the new data has been fetched * }, * }) * * if (!memberships) { * // Handle loading state * return null * } * * return ( *
*

Organization members

*
    * {memberships.data?.map((membership) => ( *
  • * {membership.publicUserData.firstName} {membership.publicUserData.lastName} < * {membership.publicUserData.identifier}> :: {membership.role} *
  • * ))} *
* * * * *
* ) * } * ``` */ declare function useOrganization(params?: T): UseOrganizationReturn; /** * @interface */ type UseOrganizationListParams = { /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * *
    *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ userMemberships?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * *
    *
  • `status`: A string that filters the invitations by the provided status.
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ userInvitations?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * *
    *
  • `status`: A string that filters the suggestions by the provided status.
  • *
  • Any of the properties described in [Shared properties](#shared-properties).
  • *
*/ userSuggestions?: true | PaginatedHookConfig; }; /** * @interface */ type UseOrganizationListReturn = { /** * A boolean that indicates whether Clerk has completed initialization and there is an authenticated user. Initially `false`, becomes `true` once Clerk loads with a user. */ isLoaded: false; /** * A function that returns a `Promise` which resolves to the newly created `Organization`. */ createOrganization: undefined; /** * A function that sets the active session and/or organization. */ setActive: undefined; /** * Returns `PaginatedResources` which includes a list of the user's organization memberships. */ userMemberships: PaginatedResourcesWithDefault; /** * Returns `PaginatedResources` which includes a list of the user's organization invitations. */ userInvitations: PaginatedResourcesWithDefault; /** * Returns `PaginatedResources` which includes a list of suggestions for organizations that the user can join. */ userSuggestions: PaginatedResourcesWithDefault; } | { isLoaded: boolean; createOrganization: (CreateOrganizationParams: CreateOrganizationParams) => Promise; setActive: SetActive; userMemberships: PaginatedResources; userInvitations: PaginatedResources; userSuggestions: PaginatedResources; }; /** * The `useOrganizationList()` hook provides access to the current user's organization memberships, invitations, and suggestions. It also includes methods for creating new organizations and managing the active organization. * * @example * ### Expanding and paginating attributes * * To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. So by default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. You must pass true or an object with the desired properties to fetch and paginate the data. * * ```tsx * // userMemberships.data will never be populated * const { userMemberships } = useOrganizationList() * * // Use default values to fetch userMemberships, such as initialPage = 1 and pageSize = 10 * const { userMemberships } = useOrganizationList({ * userMemberships: true, * }) * * // Pass your own values to fetch userMemberships * const { userMemberships } = useOrganizationList({ * userMemberships: { * pageSize: 20, * initialPage: 2, // skips the first page * }, * }) * * // Aggregate pages in order to render an infinite list * const { userMemberships } = useOrganizationList({ * userMemberships: { * infinite: true, * }, * }) * ``` * * @example * ### Infinite pagination * * The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `userMemberships` attribute will be populated with the first page of the user's organization memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list. * * ```tsx {{ filename: 'src/components/JoinedOrganizations.tsx' }} * import { useOrganizationList } from '@clerk/clerk-react' * import React from 'react' * * const JoinedOrganizations = () => { * const { isLoaded, setActive, userMemberships } = useOrganizationList({ * userMemberships: { * infinite: true, * }, * }) * * if (!isLoaded) { * return <>Loading * } * * return ( * <> *
    * {userMemberships.data?.map((mem) => ( *
  • * {mem.organization.name} * *
  • * ))} *
* * * * ) * } * * export default JoinedOrganizations * ``` * * @example * ### Simple pagination * * The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `userInvitations` attribute will be populated with the first page of invitations. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of invitations. * * Notice the difference between this example's pagination and the infinite pagination example above. * * ```tsx {{ filename: 'src/components/UserInvitationsTable.tsx' }} * import { useOrganizationList } from '@clerk/clerk-react' * import React from 'react' * * const UserInvitationsTable = () => { * const { isLoaded, userInvitations } = useOrganizationList({ * userInvitations: { * infinite: true, * keepPreviousData: true, * }, * }) * * if (!isLoaded || userInvitations.isLoading) { * return <>Loading * } * * return ( * <> * * * * * * * * * * {userInvitations.data?.map((inv) => ( * * * * * ))} * *
EmailOrg name
{inv.emailAddress}{inv.publicOrganizationData.name}
* * * * * ) * } * * export default UserInvitationsTable * ``` */ declare function useOrganizationList(params?: T): UseOrganizationListReturn; /** * @internal */ declare const useSafeLayoutEffect: typeof React.useLayoutEffect; type UseSession = () => UseSessionReturn; /** * The `useSession()` hook provides access to the current user's [`Session`](https://clerk.com/docs/references/javascript/session) object, as well as helpers for setting the active session. * * @unionReturnHeadings * ["Initialization", "Signed out", "Signed in"] * * @function * * @param [options] - An object containing options for the `useSession()` hook. * * @example * ### Access the `Session` object * * The following example uses the `useSession()` hook to access the `Session` object, which has the `lastActiveAt` property. The `lastActiveAt` property is a `Date` object used to show the time the session was last active. * * * * * ```tsx {{ filename: 'src/Home.tsx' }} * import { useSession } from '@clerk/clerk-react' * * export default function Home() { * const { isLoaded, session, isSignedIn } = useSession() * * if (!isLoaded) { * // Handle loading state * return null * } * if (!isSignedIn) { * // Handle signed out state * return null * } * * return ( *
*

This session has been active since {session.lastActiveAt.toLocaleString()}

*
* ) * } * ``` * *
* * * {@include ../../../docs/use-session.md#nextjs-01} * * *
*/ declare const useSession: UseSession; /** * The `useSessionList()` hook returns an array of [`Session`](https://clerk.com/docs/references/javascript/session) objects that have been registered on the client device. * * @unionReturnHeadings * ["Initialization", "Loaded"] * * @function * * @example * ### Get a list of sessions * * The following example uses `useSessionList()` to get a list of sessions that have been registered on the client device. The `sessions` property is used to show the number of times the user has visited the page. * * * * * ```tsx {{ filename: 'src/Home.tsx' }} * import { useSessionList } from '@clerk/clerk-react' * * export default function Home() { * const { isLoaded, sessions } = useSessionList() * * if (!isLoaded) { * // Handle loading state * return null * } * * return ( *
*

Welcome back. You've been here {sessions.length} times before.

*
* ) * } * ``` * *
* * * {@include ../../../docs/use-session-list.md#nextjs-01} * * *
*/ declare const useSessionList: () => UseSessionListReturn; /** * The `useUser()` hook provides access to the current user's [`User`](https://clerk.com/docs/references/javascript/user) object, which contains all the data for a single user in your application and provides methods to manage their account. This hook also allows you to check if the user is signed in and if Clerk has loaded and initialized. * * @unionReturnHeadings * ["Initialization", "Signed out", "Signed in"] * * @example * ### Get the current user * * The following example uses the `useUser()` hook to access the [`User`](https://clerk.com/docs/references/javascript/user) object, which contains the current user's data such as their full name. The `isLoaded` and `isSignedIn` properties are used to handle the loading state and to check if the user is signed in, respectively. * * ```tsx {{ filename: 'src/Example.tsx' }} * import { useUser } from '@clerk/clerk-react' * * export default function Example() { * const { isSignedIn, user, isLoaded } = useUser() * * if (!isLoaded) { * return
Loading...
* } * * if (!isSignedIn) { * return
Sign in to view this page
* } * * return
Hello {user.firstName}!
* } * ``` * * @example * ### Update user data * * The following example uses the `useUser()` hook to access the [`User`](https://clerk.com/docs/references/javascript/user) object, which calls the [`update()`](https://clerk.com/docs/references/javascript/user#update) method to update the current user's information. * * * * * ```tsx {{ filename: 'src/Home.tsx' }} * import { useUser } from '@clerk/clerk-react' * * export default function Home() { * const { isSignedIn, isLoaded, user } = useUser() * * if (!isLoaded) { * // Handle loading state * return null * } * * if (!isSignedIn) return null * * const updateUser = async () => { * await user.update({ * firstName: 'John', * lastName: 'Doe', * }) * } * * return ( * <> * *

user.firstName: {user.firstName}

*

user.lastName: {user.lastName}

* * ) * } * ``` *
* * * {@include ../../../docs/use-user.md#nextjs-01} * * *
* * @example * ### Reload user data * * The following example uses the `useUser()` hook to access the [`User`](https://clerk.com/docs/references/javascript/user) object, which calls the [`reload()`](https://clerk.com/docs/references/javascript/user#reload) method to get the latest user's information. * * * * * ```tsx {{ filename: 'src/Home.tsx' }} * import { useUser } from '@clerk/clerk-react' * * export default function Home() { * const { isSignedIn, isLoaded, user } = useUser(); * * if (!isLoaded) { * // Handle loading state * return null; * } * * if (!isSignedIn) return null; * * const updateUser = async () => { * // Update data via an API endpoint * const updateMetadata = await fetch('/api/updateMetadata', { * method: 'POST', * body: JSON.stringify({ * role: 'admin' * }) * }); * * // Check if the update was successful * if ((await updateMetadata.json()).message !== 'success') { * throw new Error('Error updating'); * } * * // If the update was successful, reload the user data * await user.reload(); * }; * * return ( * <> * *

user role: {user.publicMetadata.role}

* * ); * } * ``` * *
* * * {@include ../../../docs/use-user.md#nextjs-02} * * *
*/ declare function useUser(): UseUserReturn; /** * > [!WARNING] * > This hook should only be used for advanced use cases, such as building a completely custom OAuth flow or as an escape hatch to access to the `Clerk` object. * * The `useClerk()` hook provides access to the [`Clerk`](https://clerk.com/docs/references/javascript/clerk) object, allowing you to build alternatives to any Clerk Component. * * @function * * @returns The `useClerk()` hook returns the `Clerk` object, which includes all the methods and properties listed in the [`Clerk` reference](https://clerk.com/docs/references/javascript/clerk). * * @example * * The following example uses the `useClerk()` hook to access the `clerk` object. The `clerk` object is used to call the [`openSignIn()`](https://clerk.com/docs/references/javascript/clerk#sign-in) method to open the sign-in modal. * * * * * ```tsx {{ filename: 'src/Home.tsx' }} * import { useClerk } from '@clerk/clerk-react' * * export default function Home() { * const clerk = useClerk() * * return * } * ``` * * * * * {@include ../../../docs/use-clerk.md#nextjs-01} * * * */ declare const useClerk: () => LoadedClerk; type UseMemoFactory = () => T; type UseMemoDependencyArray = Exclude[1], 'undefined'>; type UseDeepEqualMemo = (factory: UseMemoFactory, dependencyArray: UseMemoDependencyArray) => T; /** * @internal */ declare const useDeepEqualMemo: UseDeepEqualMemo; /** * @internal */ declare const isDeeplyEqual: typeof dequal; type ExcludeClerkError = T extends { clerk_error: any; } ? never : T; /** * @interface */ type NeedsReverificationParameters = { cancel: () => void; complete: () => void; level: SessionVerificationLevel | undefined; }; /** * The optional options object. * @interface */ type UseReverificationOptions = { /** * A handler that is called when reverification is needed, this will opt-out of using the default UI when provided. * * @param cancel - A function that will cancel the reverification process. * @param complete - A function that will retry the original request after reverification. * @param level - The level returned with the reverification hint. * */ onNeedsReverification?: (properties: NeedsReverificationParameters) => void; }; /** * @interface */ type UseReverificationResult Promise | undefined> = (...args: Parameters) => Promise>>>; /** * @interface */ type UseReverification = Promise | undefined, Options extends UseReverificationOptions = UseReverificationOptions>(fetcher: Fetcher, options?: Options) => UseReverificationResult; /** * > [!WARNING] * > * > Depending on the SDK you're using, this feature requires `@clerk/nextjs@6.12.7` or later, `@clerk/clerk-react@5.25.1` or later, and `@clerk/clerk-js@5.57.1` or later. * * The `useReverification()` hook is used to handle a session's reverification flow. If a request requires reverification, a modal will display, prompting the user to verify their credentials. Upon successful verification, the original request will automatically retry. * * @function * * @returns The `useReverification()` hook returns an array with the "enhanced" fetcher. * * @example * ### Handle cancellation of the reverification process * * The following example demonstrates how to handle scenarios where a user cancels the reverification flow, such as closing the modal, which might result in `myData` being `null`. * * In the following example, `myFetcher` would be a function in your backend that fetches data from the route that requires reverification. See the [guide on how to require reverification](https://clerk.com/docs/guides/reverification) for more information. * * ```tsx {{ filename: 'src/components/MyButton.tsx' }} * import { useReverification } from '@clerk/clerk-react' * import { isReverificationCancelledError } from '@clerk/clerk-react/error' * * type MyData = { * balance: number * } * * export function MyButton() { * const fetchMyData = () => fetch('/api/balance').then(res=> res.json() as Promise) * const enhancedFetcher = useReverification(fetchMyData); * * const handleClick = async () => { * try { * const myData = await enhancedFetcher() * // ^ is types as `MyData` * } catch (e) { * // Handle error returned from the fetcher here * * // You can also handle cancellation with the following * if (isReverificationCancelledError(err)) { * // Handle the cancellation error here * } * } * } * * return * } * ``` * */ declare const useReverification: UseReverification; /** * @internal */ declare const useStatements: (params?: T | undefined) => PaginatedResources; /** * @internal */ declare const usePaymentAttempts: (params?: T | undefined) => PaginatedResources; /** * @internal */ declare const usePaymentMethods: (params?: T | undefined) => PaginatedResources; /** * @internal */ declare const usePlans: (params?: T | undefined) => PaginatedResources; type UseSubscriptionParams = { for?: ForPayerType; /** * If `true`, the previous data will be kept in the cache until new data is fetched. * * @default false */ keepPreviousData?: boolean; }; /** * @internal * * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. * * Fetches subscription data for the current user or organization. */ declare const useSubscription: (params?: UseSubscriptionParams) => { data: _clerk_types.CommerceSubscriptionResource | null | undefined; error: any; isLoading: boolean; isFetching: boolean; revalidate: () => Promise<_clerk_types.CommerceSubscriptionResource | null | undefined>; }; declare const ClerkInstanceContext: React.Context<{ value: LoadedClerk; } | undefined>; declare const useClerkInstanceContext: () => LoadedClerk; declare const UserContext: React.Context<{ value: UserResource | null | undefined; } | undefined>; declare const useUserContext: () => UserResource | null | undefined; declare const ClientContext: React.Context<{ value: ClientResource | null | undefined; } | undefined>; declare const useClientContext: () => ClientResource | null | undefined; declare const SessionContext: React.Context<{ value: SignedInSessionResource | null | undefined; } | undefined>; declare const useSessionContext: () => SignedInSessionResource | null | undefined; declare const OptionsContext: React.Context; type UseCheckoutOptions = { for?: ForPayerType; planPeriod: CommerceSubscriptionPlanPeriod; planId: string; }; declare const __experimental_CheckoutProvider: ({ children, ...rest }: PropsWithChildren) => React.JSX.Element; /** * @internal */ declare function useOptionsContext(): ClerkOptions; type OrganizationContextProps = { organization: OrganizationResource | null | undefined; }; declare const useOrganizationContext: () => { organization: OrganizationResource | null | undefined; }; declare const OrganizationProvider: ({ children, organization, swrConfig, }: PropsWithChildren) => React.JSX.Element; /** * @internal */ declare function useAssertWrappedByClerkProvider(displayNameOrFn: string | (() => void)): void; /** * Utility type that removes function properties from a type. */ type RemoveFunctions = { [K in keyof T as T[K] extends (...args: any[]) => any ? never : K]: T[K]; }; /** * Utility type that makes all properties `null`. */ type ForceNull = { [K in keyof T]: null; }; type CheckoutProperties = Omit, 'pathRoot' | 'status'>; type FetchStatusAndError = { error: ClerkAPIResponseError; fetchStatus: 'error'; } | { error: null; fetchStatus: 'idle' | 'fetching'; }; /** * @internal * On status === 'needs_initialization', all properties are null. * On status === 'needs_confirmation' or 'completed', all properties are defined the same as the CommerceCheckoutResource. */ type CheckoutPropertiesPerStatus = ({ status: Extract<__experimental_CheckoutCacheState['status'], 'needs_initialization'>; } & ForceNull) | ({ status: Extract<__experimental_CheckoutCacheState['status'], 'needs_confirmation' | 'completed'>; } & CheckoutProperties); type __experimental_UseCheckoutReturn = { checkout: FetchStatusAndError & CheckoutPropertiesPerStatus & { confirm: __experimental_CheckoutInstance['confirm']; start: __experimental_CheckoutInstance['start']; clear: () => void; finalize: (params?: { navigate?: SetActiveNavigate; }) => void; getState: () => __experimental_CheckoutCacheState; isStarting: boolean; isConfirming: boolean; }; }; type Params = Parameters[0]; declare const useCheckout: (options?: Params) => __experimental_UseCheckoutReturn; type PaymentElementError = { gateway: 'stripe'; error: { /** * For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported. */ code?: string; message?: string; type: string; }; }; type internalStripeAppearance = { colorPrimary: string; colorBackground: string; colorText: string; colorTextSecondary: string; colorSuccess: string; colorDanger: string; colorWarning: string; fontWeightNormal: string; fontWeightMedium: string; fontWeightBold: string; fontSizeXl: string; fontSizeLg: string; fontSizeSm: string; fontSizeXs: string; borderRadius: string; spacingUnit: string; }; type PaymentElementProviderProps = { checkout?: CommerceCheckoutResource | ReturnType['checkout']; stripeAppearance?: internalStripeAppearance; /** * Default to `user` if not provided. * * @default 'user' */ for?: ForPayerType; paymentDescription?: string; }; declare const PaymentElementProvider: ({ children, ...props }: PropsWithChildren) => React.JSX.Element; declare const PaymentElement: ({ fallback }: { fallback?: ReactNode; }) => React.JSX.Element; type UsePaymentElementReturn = { submit: () => Promise<{ data: { gateway: 'stripe'; paymentToken: string; }; error: null; } | { data: null; error: PaymentElementError; }>; reset: () => Promise; isFormReady: boolean; } & ({ provider: { name: 'stripe'; }; isProviderReady: true; } | { provider: undefined; isProviderReady: false; }); declare const usePaymentElement: () => UsePaymentElementReturn; export { ClerkInstanceContext, ClientContext, OptionsContext, OrganizationProvider, SessionContext, UserContext, __experimental_CheckoutProvider, PaymentElement as __experimental_PaymentElement, PaymentElementProvider as __experimental_PaymentElementProvider, useCheckout as __experimental_useCheckout, usePaymentAttempts as __experimental_usePaymentAttempts, usePaymentElement as __experimental_usePaymentElement, usePaymentMethods as __experimental_usePaymentMethods, usePlans as __experimental_usePlans, useStatements as __experimental_useStatements, useSubscription as __experimental_useSubscription, assertContextExists, createContextAndHook, isDeeplyEqual, useAssertWrappedByClerkProvider, useClerk, useClerkInstanceContext, useClientContext, useDeepEqualMemo, useOptionsContext, useOrganization, useOrganizationContext, useOrganizationList, useReverification, useSafeLayoutEffect, useSession, useSessionContext, useSessionList, useUser, useUserContext };