Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/rare-laws-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

Improve `useCheckout` error messages on mount.
10 changes: 7 additions & 3 deletions packages/shared/src/react/hooks/useCheckout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ export const useCheckout = (options?: Params): __experimental_UseCheckoutReturn

const clerk = useClerk();
const { organization } = useOrganization();
const { user } = useUser();
const { isLoaded, user } = useUser();

if (!isLoaded) {
throw new Error('Clerk: Ensure that `useCheckout` is inside a component wrapped with `<ClerkLoaded />`.');
}

if (!user) {
throw new Error('Clerk: User is not authenticated');
throw new Error('Clerk: Ensure that `useCheckout` is inside a component wrapped with `<SignedIn />`.');
}

if (forOrganization === 'organization' && !organization) {
throw new Error('Clerk: Use `setActive` to set the organization');
throw new Error('Clerk: Wrap your flow with a check for an active organization');
}

const manager = useMemo(
Expand Down
Loading