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/kadi-env-var-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/expo": major
---

fix(expo): Make publishableKey prop required and remove env var fallbacks
Copy link
Member

@wobsoriano wobsoriano Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fix(expo): Make publishableKey prop required and remove env var fallbacks
The `publishableKey` prop is now required in `ClerkProvider`. Previously, the prop was optional and would fall back to `EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY` or `CLERK_PUBLISHABLE_KEY` environment variables.
Environment variables inside `node_modules` are not inlined during production builds in React Native/Expo, which could cause apps to crash in production when the publishable key is undefined.
You must now explicitly pass the `publishableKey` prop to `ClerkProvider`:
```tsx
const publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY!;
<ClerkProvider publishableKey={publishableKey}>
{/* Your app */}
</ClerkProvider>

15 changes: 11 additions & 4 deletions packages/expo/src/provider/ClerkProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ export type ClerkProviderProps<TUi extends Ui = Ui> = 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!;
* <ClerkProvider publishableKey={publishableKey}>
* ```
*/
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
Expand Down Expand Up @@ -53,7 +60,7 @@ export function ClerkProvider<TUi extends Ui = Ui>(props: ClerkProviderProps<TUi
__experimental_resourceCache,
...rest
} = props;
const pk = publishableKey || process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY || process.env.CLERK_PUBLISHABLE_KEY || '';
const pk = publishableKey;

if (isWeb()) {
// This is needed in order for useOAuth to work correctly on web.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let __internal_clerk: HeadlessBrowserClerk | BrowserClerk | undefined;
export function createClerkInstance(ClerkClass: typeof Clerk) {
return (options?: BuildClerkOptions): HeadlessBrowserClerk | BrowserClerk => {
const {
publishableKey = process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY || process.env.CLERK_PUBLISHABLE_KEY || '',
publishableKey = '',
tokenCache = MemoryTokenCache,
__experimental_resourceCache: createResourceCache,
} = options || {};
Expand Down
Loading