Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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/fix-query-client-rn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/expo": patch
---

Fix `useOrganizationList` and other query-based hooks returning empty data on React Native by synchronously providing a `QueryClient` instance
1 change: 1 addition & 0 deletions packages/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"@clerk/clerk-js": "workspace:^",
"@clerk/react": "workspace:^",
"@clerk/shared": "workspace:^",
"@tanstack/query-core": "5.90.16",
"base-64": "^1.0.0",
"react-native-url-polyfill": "2.0.0",
"tslib": "catalog:repo"
Expand Down
20 changes: 20 additions & 0 deletions packages/expo/src/provider/singleton/createClerkInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ export function createClerkInstance(ClerkClass: typeof Clerk) {
__internal_clerkOptions = { publishableKey, proxyUrl, domain };
__internal_clerk = new ClerkClass(publishableKey, { proxyUrl, domain }) as unknown as BrowserClerk;

// The clerk-js native bundle uses rspack code-splitting for the internal QueryClient.
// On React Native, rspack's chunk loading doesn't work (Metro bundles into a single file),
// so the dynamic import never resolves and __internal_queryClient stays undefined.
// This breaks hooks that depend on the query client (useOrganizationList, etc.).
// Override the getter to synchronously create a QueryClient on first access.
{
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { QueryClient } = require('@tanstack/query-core');
let queryClient: InstanceType<typeof QueryClient> | undefined;
Object.defineProperty(__internal_clerk, '__internal_queryClient', {
get() {
if (!queryClient) {
queryClient = new QueryClient();
}
return { __tag: 'clerk-rq-client', client: queryClient };
},
configurable: true,
});
}

if (Platform.OS === 'ios' || Platform.OS === 'android') {
// @ts-expect-error - This is an internal API
__internal_clerk.__internal_createPublicCredentials = (
Expand Down
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading