Skip to content
Open
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/modern-hornets-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/react": patch
---

Fix `ReferenceError: Property 'document' doesn't exist` crash in React Native environments by conditionally loading UI scripts only in standard browser contexts.
6 changes: 4 additions & 2 deletions packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,14 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
}

try {
const clerkUICtor = await this.getClerkUiEntryChunk();
const clerk = await this.getClerkJsEntryChunk();

if (!clerk.loaded) {
this.beforeLoad(clerk);
await clerk.load({ ...this.options, clerkUICtor });
// Only load UI scripts in standard browser environments (not native/headless)
const shouldLoadUi = !this.options.Clerk && this.options.standardBrowser !== false;
const clerkUiCtor = shouldLoadUi ? await this.getClerkUiEntryChunk() : undefined;
await clerk.load({ ...this.options, clerkUiCtor });
}
if (clerk.loaded) {
this.replayInterceptedInvocations(clerk);
Expand Down
Loading