From bf55730b27109d286a3cfb8cf0be5feedfa9b24f Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 22 Jan 2026 13:56:39 -0800 Subject: [PATCH 1/2] fix(expo): Make publishableKey prop required and remove env var fallbacks --- .changeset/kadi-env-var-fix.md | 18 ++++++++++++++++++ packages/expo/src/provider/ClerkProvider.tsx | 15 +++++++++++---- .../provider/singleton/createClerkInstance.ts | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .changeset/kadi-env-var-fix.md diff --git a/.changeset/kadi-env-var-fix.md b/.changeset/kadi-env-var-fix.md new file mode 100644 index 00000000000..f77a7331f7d --- /dev/null +++ b/.changeset/kadi-env-var-fix.md @@ -0,0 +1,18 @@ +--- +"@clerk/expo": major +--- + +fix(expo): Make publishableKey prop required and remove env var fallbacks + +Made `publishableKey` a required prop in `ClerkProvider` since environment variables inside node_modules are not inlined during production builds. This was causing apps to work in development but crash in production TestFlight/Google Play builds because the env var would be unset. + +**Migration:** Pass the publishable key explicitly to ClerkProvider: + +```tsx +// Before (no longer works in production) + + +// After +const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!; + +``` diff --git a/packages/expo/src/provider/ClerkProvider.tsx b/packages/expo/src/provider/ClerkProvider.tsx index cea114a6e43..6c81616a1fc 100644 --- a/packages/expo/src/provider/ClerkProvider.tsx +++ b/packages/expo/src/provider/ClerkProvider.tsx @@ -14,10 +14,17 @@ export type ClerkProviderProps = Omit< 'publishableKey' > & { /** - * Used to override the default EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY env variable if needed. - * This is optional for Expo as the ClerkProvider will automatically use the EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY env variable if it exists. + * Your Clerk publishable key, available in the Clerk Dashboard. + * This is required for React Native / Expo apps. Environment variables inside node_modules + * are not inlined during production builds, so the key must be passed explicitly. + * + * @example + * ```tsx + * const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!; + * + * ``` */ - publishableKey?: string; + publishableKey: string; /** * The token cache is used to persist the active user's session token. Clerk stores this token in memory by default, however it is recommended to use a token cache for production applications. * @see https://clerk.com/docs/quickstarts/expo#configure-the-token-cache-with-expo @@ -53,7 +60,7 @@ export function ClerkProvider(props: ClerkProviderProps { const { - publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY || process.env.CLERK_PUBLISHABLE_KEY || '', + publishableKey = '', tokenCache = MemoryTokenCache, __experimental_resourceCache: createResourceCache, } = options || {}; From b23a007cdbfdb2e9670c13475618ce32bc94f551 Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 22 Jan 2026 14:17:24 -0800 Subject: [PATCH 2/2] fix(expo): Require publishableKey prop in ClerkProvider to prevent production crashes --- .changeset/kadi-env-var-fix.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.changeset/kadi-env-var-fix.md b/.changeset/kadi-env-var-fix.md index f77a7331f7d..806afaa9405 100644 --- a/.changeset/kadi-env-var-fix.md +++ b/.changeset/kadi-env-var-fix.md @@ -3,16 +3,3 @@ --- fix(expo): Make publishableKey prop required and remove env var fallbacks - -Made `publishableKey` a required prop in `ClerkProvider` since environment variables inside node_modules are not inlined during production builds. This was causing apps to work in development but crash in production TestFlight/Google Play builds because the env var would be unset. - -**Migration:** Pass the publishable key explicitly to ClerkProvider: - -```tsx -// Before (no longer works in production) - - -// After -const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!; - -```