From eb8623a848cfd8728d31f2828da7d61dea5b958d Mon Sep 17 00:00:00 2001 From: Stefanos Anagnostou Date: Mon, 17 Mar 2025 13:49:40 +0200 Subject: [PATCH 1/2] fix(clerk-expo): Add console error for disabled Native API --- .changeset/eight-paws-add.md | 5 +++++ .../expo/src/provider/singleton/createClerkInstance.ts | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changeset/eight-paws-add.md diff --git a/.changeset/eight-paws-add.md b/.changeset/eight-paws-add.md new file mode 100644 index 00000000000..d262779e82f --- /dev/null +++ b/.changeset/eight-paws-add.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-expo': patch +--- + +Add a console error if the Native API is disabled for the instance. diff --git a/packages/expo/src/provider/singleton/createClerkInstance.ts b/packages/expo/src/provider/singleton/createClerkInstance.ts index b62d3d42c50..e3b9a444859 100644 --- a/packages/expo/src/provider/singleton/createClerkInstance.ts +++ b/packages/expo/src/provider/singleton/createClerkInstance.ts @@ -168,12 +168,20 @@ export function createClerkInstance(ClerkClass: typeof Clerk) { } }); + let nativeApiErrorShown = false; // @ts-expect-error - This is an internal API __internal_clerk.__unstable__onAfterResponse(async (_: FapiRequestInit, response: FapiResponse) => { const authHeader = response.headers.get('authorization'); if (authHeader) { await saveToken(KEY, authHeader); } + + if (!nativeApiErrorShown && response.payload?.errors?.[0]?.code === 'native_api_disabled') { + console.error( + 'Clerk: The Native API is disabled for this instance.\nGo to Clerk Dashboard > Configure > Native applications to enable it.', + ); + nativeApiErrorShown = true; + } }); } return __internal_clerk; From 3570f51d4e56733eac88f7d3f17c18e2b49d15e4 Mon Sep 17 00:00:00 2001 From: Stefanos Anagnostou Date: Mon, 17 Mar 2025 14:19:20 +0200 Subject: [PATCH 2/2] add a url to the message --- packages/expo/src/provider/singleton/createClerkInstance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/expo/src/provider/singleton/createClerkInstance.ts b/packages/expo/src/provider/singleton/createClerkInstance.ts index e3b9a444859..2a4f06b0ffd 100644 --- a/packages/expo/src/provider/singleton/createClerkInstance.ts +++ b/packages/expo/src/provider/singleton/createClerkInstance.ts @@ -178,7 +178,7 @@ export function createClerkInstance(ClerkClass: typeof Clerk) { if (!nativeApiErrorShown && response.payload?.errors?.[0]?.code === 'native_api_disabled') { console.error( - 'Clerk: The Native API is disabled for this instance.\nGo to Clerk Dashboard > Configure > Native applications to enable it.', + 'The Native API is disabled for this instance.\nGo to Clerk Dashboard > Configure > Native applications to enable it.\nOr, navigate here: https://dashboard.clerk.com/last-active?path=native-applications', ); nativeApiErrorShown = true; }