Skip to content
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
780cae5
Initial setup
SarahSoutoul Sep 30, 2025
128df3c
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Sep 30, 2025
a584905
Test
SarahSoutoul Oct 1, 2025
8d2e9e2
Refactor typedoc
SarahSoutoul Oct 1, 2025
70c5908
Bring back removed info
SarahSoutoul Oct 1, 2025
d49447e
Add missing code templating
SarahSoutoul Oct 1, 2025
7b9b11b
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 1, 2025
b653539
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 2, 2025
3f1f920
Remove jsdocs changes to have in separate PR
SarahSoutoul Oct 2, 2025
3cc87f9
Bring back session list
SarahSoutoul Oct 2, 2025
64da460
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 2, 2025
16f9663
Fix setActive returns
SarahSoutoul Oct 2, 2025
febc294
Fix returns for useAuth
SarahSoutoul Oct 2, 2025
c32a435
Update the custom theme to get the useAuth options markdown generated…
NWylynko Oct 3, 2025
263dba2
replace @unionInline with @embedType that covers more type inlining
NWylynko Oct 7, 2025
316c861
Fix SetActive return after Nick fix
SarahSoutoul Oct 7, 2025
40dbc8b
Add new extract returns and params script
NWylynko Oct 8, 2025
bc7873c
Add new extract returns and params script
NWylynko Oct 8, 2025
2ebb4f2
Remove unwanted changes
SarahSoutoul Oct 8, 2025
906c42c
Billing hooks jsdoc work
SarahSoutoul Oct 9, 2025
113bb22
Refine useCheckout
SarahSoutoul Oct 10, 2025
d58bcbd
Add billing hooks params to files without headings
SarahSoutoul Oct 10, 2025
3bde171
Fix some issues billing hooks
SarahSoutoul Oct 10, 2025
ecd1435
Additional fixes and clean up
SarahSoutoul Oct 10, 2025
3262527
Clean up PR
SarahSoutoul Oct 13, 2025
11d3506
Fix conflicts
SarahSoutoul Oct 13, 2025
6bdc23d
Remove unnecessary comment
SarahSoutoul Oct 14, 2025
b6b7f80
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 14, 2025
f0ebf2e
Replace link
SarahSoutoul Oct 14, 2025
1cfd43a
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 15, 2025
038c99d
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 15, 2025
45f698d
Changes post coderabbit feedback
SarahSoutoul Oct 15, 2025
9f9ce0e
Add changeset
SarahSoutoul Oct 15, 2025
4cd4165
Fix typo spotted by code rabbit
SarahSoutoul Oct 15, 2025
b1888f9
Fix build issues
SarahSoutoul Oct 15, 2025
912fa9c
Fix headings for usePaymentElement
SarahSoutoul Oct 16, 2025
5c29779
Fix added comments by formatter
SarahSoutoul Oct 16, 2025
6b4f930
Simplify returns useSubscription
SarahSoutoul Oct 16, 2025
9df0c27
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 20, 2025
9430645
Resolve coderabbit feedback
SarahSoutoul Oct 23, 2025
c0b8e19
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 23, 2025
32a4c45
Fix link useCheckout and types useSubscription
SarahSoutoul Oct 24, 2025
db76fb7
Refinements code rabbit feedback
SarahSoutoul Oct 24, 2025
9ff65e9
Change finalize comment
SarahSoutoul Oct 24, 2025
a8c4ada
Change description useReverification for consistency
SarahSoutoul Oct 24, 2025
9e4f120
Minor refinements code rabbit
SarahSoutoul Oct 24, 2025
9b36954
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 30, 2025
3029aa3
Merge branch 'main' into ss/DOCS-10983
SarahSoutoul Oct 30, 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
21 changes: 20 additions & 1 deletion .typedoc/custom-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const FILES_WITHOUT_HEADINGS = [
'use-organization-params.mdx',
'paginated-resources.mdx',
'pages-or-infinite-options.mdx',
'pages-or-infinite-options.mdx',
'paginated-hook-config.mdx',
'use-organization-list-return.mdx',
'use-organization-list-params.mdx',
Expand All @@ -19,6 +18,19 @@ const FILES_WITHOUT_HEADINGS = [
'verify-token-options.mdx',
'public-organization-data-json.mdx',
'organization-membership-public-user-data.mdx',
'use-checkout-return.mdx',
'use-checkout-options.mdx',
'use-payment-element-return.mdx',
'use-payment-methods-return.mdx',
'use-payment-attempts-return.mdx',
'use-plans-return.mdx',
'use-statements-return.mdx',
'hook-params.mdx',
'use-subscription-params.mdx',
'use-subscription-return.mdx',
'needs-reverification-parameters.mdx',
'use-reverification-options.mdx',
'use-reverification-params,mdx',
];

/**
Expand All @@ -29,6 +41,9 @@ const LINK_REPLACEMENTS = [
['set-active-params', '/docs/reference/javascript/types/set-active-params'],
['clerk-paginated-response', '/docs/reference/javascript/types/clerk-paginated-response'],
['paginated-resources', '#paginated-resources'],
['use-checkout-options', '#use-checkout-options'],
['use-reverification-options', '#use-reverification-options'],
['needs-reverification-parameters', '#needs-reverification-parameters'],
['create-organization-params', '#create-organization-params'],
['session-resource', '/docs/reference/javascript/session'],
['signed-in-session-resource', '/docs/reference/javascript/session'],
Expand Down Expand Up @@ -62,10 +77,14 @@ const LINK_REPLACEMENTS = [
['billing-payer-resource', '/docs/reference/javascript/types/billing-payer-resource'],
['billing-plan-resource', '/docs/reference/javascript/types/billing-plan-resource'],
['billing-checkout-totals', '/docs/reference/javascript/types/billing-checkout-totals'],
['billing-checkout-resource', '/docs/reference/javascript/types/billing-checkout-resource'],
['billing-money-amount', '/docs/reference/javascript/types/billing-money-amount'],
['billing-subscription-item-resource', '/docs/reference/javascript/types/billing-subscription-item-resource'],
['feature-resource', '/docs/reference/javascript/types/feature-resource'],
['billing-statement-group', '/docs/reference/javascript/types/billing-statement-group'],
['billing-statement-resource', '/docs/reference/javascript/types/billing-statement-resource'],
['billing-subscription-resource', '/docs/reference/javascript/types/billing-subscription-resource'],
['clerk-api-response-error', '/docs/reference/javascript/types/clerk-api-response-error'],
['billing-statement-totals', '/docs/reference/javascript/types/billing-statement-totals'],
['billing-payment-resource', '/docs/reference/javascript/types/billing-payment-resource'],
['deleted-object-resource', '/docs/reference/javascript/types/deleted-object-resource'],
Expand Down
164 changes: 164 additions & 0 deletions .typedoc/extract-returns-and-params.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// @ts-check
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
* Extracts the "## Returns" section from a markdown file and writes it to a separate file.
* @param {string} filePath - The path to the markdown file
* @returns {boolean} True if a file was created
*/
function extractReturnsSection(filePath) {
const content = fs.readFileSync(filePath, 'utf-8');

// Find the "## Returns" section
const returnsStart = content.indexOf('## Returns');

if (returnsStart === -1) {
return false; // No Returns section found
}

// Find the next heading after "## Returns" (or end of file)
const afterReturns = content.slice(returnsStart + 10); // Skip past "## Returns"
const nextHeadingMatch = afterReturns.match(/\n## /);
const returnsEnd =
nextHeadingMatch && typeof nextHeadingMatch.index === 'number'
? returnsStart + 10 + nextHeadingMatch.index
: content.length;

// Extract the Returns section and trim trailing whitespace
const returnsContent = content.slice(returnsStart, returnsEnd).trimEnd();

// Generate the new filename: use-auth.mdx -> use-auth-return.mdx
const fileName = path.basename(filePath, '.mdx');
const dirName = path.dirname(filePath);
const newFilePath = path.join(dirName, `${fileName}-return.mdx`);

// Write the extracted Returns section to the new file
fs.writeFileSync(newFilePath, returnsContent, 'utf-8');

console.log(`[extract-returns] Created ${path.relative(process.cwd(), newFilePath)}`);
return true;
}

/**
* Extracts the "## Parameters" section from a markdown file and writes it to a separate file.
* @param {string} filePath - The path to the markdown file
* @param {string} dirName - The directory containing the files
* @returns {boolean} True if a file was created
*/
function extractParametersSection(filePath, dirName) {
const content = fs.readFileSync(filePath, 'utf-8');
const fileName = path.basename(filePath, '.mdx');

Comment on lines +62 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Params written to wrong directory; props deletion path wrong (critical).

extractParametersSection writes -params.mdx at the package root and deletes -props.mdx there, not next to the source file. This will misplace files for nested MDX and fail to delete the actual props file. Align with extractReturnsSection by using the file’s own directory and drop the extra dirName param.

Apply these diffs:

- * @param {string} dirName - The directory containing the files
  * @returns {boolean} True if a file was created
  */
-function extractParametersSection(filePath, dirName) {
+function extractParametersSection(filePath) {
-  // Delete any existing -props file (TypeDoc-generated)
-  const propsFilePath = path.join(dirName, propsFileName);
+  // Delete any existing -props file (TypeDoc-generated)
+  const dirForFile = path.dirname(filePath);
+  const propsFilePath = path.join(dirForFile, propsFileName);
-  // Write to new file
-  const newFilePath = path.join(dirName, targetFileName);
+  // Write to new file (next to source)
+  const newFilePath = path.join(dirForFile, targetFileName);
   fs.writeFileSync(newFilePath, paramsContent, 'utf-8');
-      // Extract Parameters sections
-      if (extractParametersSection(filePath, dir)) {
+      // Extract Parameters sections
+      if (extractParametersSection(filePath)) {
         paramsCount++;
       }

Also applies to: 62-67, 87-90, 154-156

🤖 Prompt for AI Agents
In .typedoc/extract-returns-and-params.mjs around lines 48-56 (and also update
the similar blocks at 62-67, 87-90, and 154-156): the function currently writes
the -params.mdx file to the package root and deletes the -props.mdx from the
wrong location because it uses the passed dirName; change the logic to derive
the target directory from the source file itself (use path.dirname(filePath))
and remove the extra dirName parameter so the new -params.mdx is written next to
the source MDX and the corresponding -props.mdx deletion targets the same
directory, mirroring the behavior of extractReturnsSection.

// Always use -params suffix
const suffix = '-params';
const targetFileName = `${fileName}${suffix}.mdx`;
const propsFileName = `${fileName}-props.mdx`;

// Delete any existing -props file (TypeDoc-generated)
const propsFilePath = path.join(dirName, propsFileName);
if (fs.existsSync(propsFilePath)) {
fs.unlinkSync(propsFilePath);
console.log(`[extract-returns] Deleted ${path.relative(process.cwd(), propsFilePath)}`);
}

// Find the "## Parameters" section
const paramsStart = content.indexOf('## Parameters');

if (paramsStart === -1) {
return false; // No Parameters section found
}

// Find the next heading after "## Parameters" (or end of file)
const afterParams = content.slice(paramsStart + 13); // Skip past "## Parameters"
const nextHeadingMatch = afterParams.match(/\n## /);
const paramsEnd =
nextHeadingMatch && typeof nextHeadingMatch.index === 'number'
? paramsStart + 13 + nextHeadingMatch.index
: content.length;

// Extract the Parameters section and trim trailing whitespace
const paramsContent = content.slice(paramsStart, paramsEnd).trimEnd();

// Write to new file
const newFilePath = path.join(dirName, targetFileName);
fs.writeFileSync(newFilePath, paramsContent, 'utf-8');

console.log(`[extract-returns] Created ${path.relative(process.cwd(), newFilePath)}`);
return true;
}

/**
* Recursively reads all .mdx files in a directory, excluding generated files
* @param {string} dir - The directory to read
* @returns {string[]} Array of file paths
*/
function getAllMdxFiles(dir) {
/** @type {string[]} */
const files = [];

if (!fs.existsSync(dir)) {
return files;
}

const entries = fs.readdirSync(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.isDirectory()) {
files.push(...getAllMdxFiles(fullPath));
} else if (entry.isFile() && entry.name.endsWith('.mdx')) {
// Exclude generated files
const isGenerated =
entry.name.endsWith('-return.mdx') || entry.name.endsWith('-params.mdx') || entry.name.endsWith('-props.mdx');
if (!isGenerated) {
files.push(fullPath);
}
}
}

return files;
}

/**
* Main function to process all clerk-react files
*/
function main() {
const packages = ['clerk-react'];
const dirs = packages.map(folder => path.join(__dirname, 'temp-docs', folder));

for (const dir of dirs) {
if (!fs.existsSync(dir)) {
console.log(`[extract-returns] ${dir} directory not found, skipping extraction`);
continue;
}

const mdxFiles = getAllMdxFiles(dir);
console.log(`[extract-returns] Processing ${mdxFiles.length} files in ${dir}/`);

let returnsCount = 0;
let paramsCount = 0;

for (const filePath of mdxFiles) {
// Extract Returns sections
if (extractReturnsSection(filePath)) {
returnsCount++;
}

// Extract Parameters sections
if (extractParametersSection(filePath, dir)) {
paramsCount++;
}
}

console.log(`[extract-returns] Extracted ${returnsCount} Returns sections`);
console.log(`[extract-returns] Extracted ${paramsCount} Parameters sections`);
}
}

main();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"test:typedoc": "pnpm typedoc:generate && cd ./.typedoc && vitest run",
"turbo:clean": "turbo daemon clean",
"typedoc:generate": "pnpm build:declarations && pnpm typedoc:generate:skip-build",
"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && rm -rf .typedoc/docs && mv .typedoc/temp-docs .typedoc/docs",
"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rm -rf .typedoc/docs && mv .typedoc/temp-docs .typedoc/docs",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Make script cross‑platform (avoid POSIX rm/mv).

rm -rf and mv break on Windows. Use existing rimraf and cpy-cli instead.

Apply this diff:

-"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rm -rf .typedoc/docs && mv .typedoc/temp-docs .typedoc/docs",
+"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rimraf .typedoc/docs && cpy \".typedoc/temp-docs/**\" .typedoc/docs --parents && rimraf .typedoc/temp-docs",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rm -rf .typedoc/docs && mv .typedoc/temp-docs .typedoc/docs",
"typedoc:generate:skip-build": "typedoc --tsconfig tsconfig.typedoc.json && node .typedoc/extract-returns-and-params.mjs && rimraf .typedoc/docs && cpy \".typedoc/temp-docs/**\" .typedoc/docs --parents && rimraf .typedoc/temp-docs",
🤖 Prompt for AI Agents
In package.json at line 60, the typedoc:generate:skip-build script uses
POSIX-only rm and mv which fail on Windows; update the script to use the
project's cross-platform tools (rimraf to remove .typedoc/docs and cpy-cli to
move or copy .typedoc/temp-docs into .typedoc/docs) and ensure flags preserve
recursive behavior; keep the existing typedoc and node steps, then run rimraf
.typedoc/docs and use cpy (or cpy-cli) to copy all files from .typedoc/temp-docs
to .typedoc/docs, and finally remove .typedoc/temp-docs with rimraf if desired.

"version-packages": "changeset version && pnpm install --lockfile-only --engine-strict=false",
"version-packages:canary": "./scripts/canary.mjs",
"version-packages:snapshot": "./scripts/snapshot.mjs",
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/src/errors/clerkApiResponseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface ClerkAPIResponseOptions extends Omit<ClerkErrorParams, 'message' | 'co
retryAfter?: number;
}

/**
* Interface representing a Clerk API Response Error.
*/
Comment on lines 14 to 16
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

JSDoc mismatch: refers to “Interface” but documents a class; enrich for Typedoc

Replace the summary and add basic tags to align with the PR goal (Typedoc metadata).

Apply this diff:

-/**
- * Interface representing a Clerk API Response Error.
- */
+/**
+ * Class representing a Clerk API response error thrown when the Clerk API returns an error payload.
+ * @public
+ * @remarks Use `status`, `errors`, `clerkTraceId`, and `retryAfter` to inspect details.
+ * @see isClerkApiResponseError
+ */

Additionally (outside this range), consider:

  • Add JSDoc to public fields so Typedoc shows property descriptions.
  • Add explicit return types to methods to satisfy coding guidelines.

Example snippet:

export class ClerkAPIResponseError extends ClerkError implements ClerkAPIResponseErrorInterface {
  /** HTTP status code returned by the API. */
  public status: number;

  /** Unique trace identifier for support/debugging. */
  public clerkTraceId?: string;

  /** Retry-After value (in seconds) when rate limited or similar. */
  public retryAfter?: number;

  /** Parsed list of API errors. */
  public errors: ClerkAPIError[];

  /** Returns a stringified representation of this error. */
  public toString(): string { /* unchanged body */ }

  // Keeps message unformatted for backward compatibility
  protected static override formatMessage(name: string, msg: string, _: string, __: string | undefined): string {
    return msg;
  }
}

Please re-run your Typedoc flow (pnpm run typedoc:generate) to confirm the class and its members render with the updated descriptions, and that constructor params/fields appear as expected. As per coding guidelines.


🏁 Script executed:

#!/bin/bash
file=$(fd clerkApiResponseError.ts)
echo "Found file: $file"
sed -n '1,30p' "$file"

Length of output: 1203


🏁 Script executed:

#!/bin/bash
file="packages/shared/src/errors/clerkApiResponseError.ts"
sed -n '30,100p' "$file"

Length of output: 1081


Fix JSDoc header and document public API

Replace at packages/shared/src/errors/clerkApiResponseError.ts (lines 15–17):

-/**
- * Interface representing a Clerk API Response Error.
- */
+/**
+ * Class representing a Clerk API response error thrown when the Clerk API returns an error payload.
+ * @public
+ * @remarks Use `status`, `errors`, `clerkTraceId`, and `retryAfter` to inspect details.
+ * @see isClerkApiResponseError
+ */
  • Add JSDoc comments to each public property (status, clerkTraceId, retryAfter, errors).
  • Annotate toString() and protected static override formatMessage() with an explicit : string return type.
    [must_fix]
🤖 Prompt for AI Agents
In packages/shared/src/errors/clerkApiResponseError.ts around lines 15 to 17,
the file is missing JSDoc on public properties and explicit return type
annotations on two methods; add clear JSDoc comments above each public property
(status, clerkTraceId, retryAfter, errors) describing type and purpose, and
update the method signatures of toString() and the protected static override
formatMessage() to include an explicit ": string" return type; ensure the JSDoc
uses standard /** ... */ format and mentions visibility (public) where
appropriate.

export class ClerkAPIResponseError extends ClerkError implements ClerkAPIResponseErrorInterface {
static name = 'ClerkAPIResponseError';
status: number;
Expand Down
51 changes: 45 additions & 6 deletions packages/shared/src/react/commerce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useSWR from 'swr';
import useSWRMutation from 'swr/mutation';

import { createContextAndHook } from './hooks/createContextAndHook';
import type { useCheckout } from './hooks/useCheckout';
import { useClerk } from './hooks/useClerk';
import { useOrganization } from './hooks/useOrganization';
import { useUser } from './hooks/useUser';
Expand Down Expand Up @@ -139,15 +138,27 @@ type internalStripeAppearance = {
spacingUnit: string;
};

type PaymentElementProviderProps = {
checkout?: BillingCheckoutResource | ReturnType<typeof useCheckout>['checkout'];
/**
* @interface
*/
export type PaymentElementProviderProps = {
/**
* An optional checkout resource object. When provided, the payment element is scoped to the specific checkout session.
*/
checkout?: BillingCheckoutResource;
/**
* An optional object to customize the appearance of the Stripe Payment Element. This allows you to match the form's styling to your application's theme.
*/
stripeAppearance?: internalStripeAppearance;
/**
* Default to `user` if not provided.
* Specifies whether to fetch for the current user or organization.
*
* @default 'user'
*/
for?: ForPayerType;
/**
* An optional description to display to the user within the payment element UI.
*/
paymentDescription?: string;
};

Expand Down Expand Up @@ -229,7 +240,17 @@ const PaymentElementInternalRoot = (props: PropsWithChildren) => {
return <DummyStripeUtils>{props.children}</DummyStripeUtils>;
};

const PaymentElement = ({ fallback }: { fallback?: ReactNode }) => {
/**
* @interface
*/
export type PaymentElementProps = {
/**
* Optional fallback content, such as a loading skeleton, to display while the payment form is being initialized.
*/
fallback?: ReactNode;
};

const PaymentElement = ({ fallback }: PaymentElementProps) => {
const {
setIsPaymentElementReady,
paymentMethodOrder,
Expand Down Expand Up @@ -296,7 +317,13 @@ const throwLibsMissingError = () => {
);
};

type UsePaymentElementReturn = {
/**
* @interface
*/
export type UsePaymentElementReturn = {
/**
* A function that submits the payment form data to the payment provider. It returns a promise that resolves with either a `data` object containing a payment token on success, or an `error` object on failure.
*/
submit: () => Promise<
| {
data: { gateway: 'stripe'; paymentToken: string };
Expand All @@ -307,13 +334,25 @@ type UsePaymentElementReturn = {
error: PaymentElementError;
}
>;
/**
* A function that resets the payment form to its initial, empty state.
*/
reset: () => Promise<void>;
/**
* A boolean that indicates if the payment form UI has been rendered and is ready for user input. This is useful for disabling a submit button until the form is interactive.
*/
isFormReady: boolean;
} & (
| {
/**
* An object containing information about the initialized payment provider. It is `undefined` until `isProviderReady` is `true`.
*/
provider: {
name: 'stripe';
};
/**
* A boolean that indicates if the underlying payment provider (e.g. Stripe) has been fully initialized.
*/
isProviderReady: true;
}
| {
Expand Down
16 changes: 15 additions & 1 deletion packages/shared/src/react/contexts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ const [SessionContext, useSessionContext] = createContextAndHook<SignedInSession

const OptionsContext = React.createContext<ClerkOptions>({});

type UseCheckoutOptions = {
/**
* @interface
*/
export type UseCheckoutOptions = {
/**
* Specifies if the checkout is for an organization.
*
* @default 'user'
*/
for?: ForPayerType;
/**
* The billing period for the plan.
*/
planPeriod: BillingSubscriptionPlanPeriod;
/**
* The ID of the subscription plan to check out (e.g. `cplan_xxx`).
*/
planId: string;
};

Expand Down
16 changes: 12 additions & 4 deletions packages/shared/src/react/hooks/createBillingPaginatedHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ type BillingHookConfig<TResource extends ClerkResource, TParams extends PagesOrI
};
};

/**
* @interface
*/
export type HookParams = PaginatedHookConfig<PagesOrInfiniteOptions> & {
/**
* Specifies whether to fetch for the current user or organization.
*
* @default 'user'
*/
for?: ForPayerType;
};

/**
* A hook factory that creates paginated data fetching hooks for commerce-related resources.
* It provides a standardized way to create hooks that can fetch either user or organization resources
Expand All @@ -44,10 +56,6 @@ export function createBillingPaginatedHook<TResource extends ClerkResource, TPar
useFetcher,
options,
}: BillingHookConfig<TResource, TParams>) {
type HookParams = PaginatedHookConfig<PagesOrInfiniteOptions> & {
for?: ForPayerType;
};

return function useBillingHook<T extends HookParams>(
params?: T,
): PaginatedResources<TResource, T extends { infinite: true } ? true : false> {
Expand Down
Loading
Loading