@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
52 lines • 1.38 kB
text/typescript
import { BillingSubscriptionResource, ForPayerType } from "../../types/billing.mjs";
//#region src/react/hooks/useSubscription.types.d.ts
/**
* @interface
*/
type UseSubscriptionParams = {
/**
* Specifies whether to fetch the Subscription for an Organization or a user.
*
* @default 'user'
*/
for?: ForPayerType;
/**
* If true, the previous data will be kept in the cache until new data is fetched.
*
* @default false
*/
keepPreviousData?: boolean;
/**
* If `true`, a request will be triggered when the hook is mounted.
*
* @default true
*/
enabled?: boolean;
};
/**
* @interface
*/
type SubscriptionResult = {
/**
* The subscription object, `undefined` before the first fetch, or `null` if no subscription exists.
*/
data: BillingSubscriptionResource | undefined | null;
/**
* Any error that occurred during the data fetch, or `undefined` if no error occurred.
*/
error: Error | undefined;
/**
* Indicates whether the initial data is still being fetched.
*/
isLoading: boolean;
/**
* Indicates whether any request is still in flight, including background updates.
*/
isFetching: boolean;
/**
* Function to manually revalidate or refresh the subscription data.
*/
revalidate: () => Promise<void> | void;
};
//#endregion
export { SubscriptionResult, UseSubscriptionParams };