Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Dec 19, 2025

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Breaking Changes

    • Removed the deprecated Clerk export from @clerk/expo — switch to getClerkInstance() for all Clerk access.
  • New Features

    • getClerkInstance() lets you initialize and use Clerk outside the Provider (non-React contexts) and supports multiple isolated instances with different publishable keys. Calling it without a publishable key before the Provider renders will throw an error.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2025

🦋 Changeset detected

Latest commit: 703ad22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/expo Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Dec 20, 2025 6:33pm
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 19, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7519 

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7519 

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7519 

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7519 

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7519 

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7519 

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7519 

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7519 

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7519 

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7519 

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7519 

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7519 

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7519 

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7519 

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7519 

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7519 

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7519 

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7519 

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7519 

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7519 

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7519 

commit: 703ad22

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

📝 Walkthrough

Walkthrough

This pull request removes the deprecated Clerk export from the @clerk/expo package and deletes exported clerk variables from provider/singleton files (createClerkInstance.ts, singleton.ts, singleton.web.ts). It introduces and documents getClerkInstance() as the primary access point, which can be called with an optional publishableKey to pre-initialize an instance outside React. Calling getClerkInstance() without a key before ClerkProvider renders throws an error; calling it with different keys produces separate Clerk instances.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(expo): Remove Clerk instance export' directly and clearly summarizes the main change: removal of the Clerk export from the @clerk/expo package.

📜 Recent review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb4ff0e and 703ad22.

📒 Files selected for processing (2)
  • .changeset/tame-carpets-sink.md (1 hunks)
  • packages/upgrade/src/versions/core-3/changes/expo-clerk-export-removed.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/upgrade/src/versions/core-3/changes/expo-clerk-export-removed.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/tame-carpets-sink.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (**)
  • GitHub Check: Static analysis
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e76d248 and cb4ff0e.

📒 Files selected for processing (5)
  • .changeset/tame-carpets-sink.md (1 hunks)
  • packages/expo/src/index.ts (0 hunks)
  • packages/expo/src/provider/singleton/createClerkInstance.ts (1 hunks)
  • packages/expo/src/provider/singleton/singleton.ts (0 hunks)
  • packages/expo/src/provider/singleton/singleton.web.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/expo/src/index.ts
  • packages/expo/src/provider/singleton/singleton.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use ESLint with custom configurations tailored for different package types

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use Prettier for code formatting across all packages

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
**/*

⚙️ CodeRabbit configuration file

If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.

**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.

Files:

  • packages/expo/src/provider/singleton/createClerkInstance.ts
  • packages/expo/src/provider/singleton/singleton.web.ts
🧬 Code graph analysis (1)
packages/expo/src/provider/singleton/createClerkInstance.ts (2)
packages/clerk-js/src/core/clerk.ts (1)
  • publishableKey (300-302)
packages/react/src/isomorphicClerk.ts (1)
  • publishableKey (175-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (25)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
import { getClerkInstance } from '@clerk/expo';

// Access the Clerk instance
const token = await getClerkInstance().session?.getToken();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Runtime error: missing optional chaining on getClerkInstance().

Since getClerkInstance() can return undefined, accessing .session directly will throw. Use optional chaining:

-const token = await getClerkInstance().session?.getToken(); +const token = await getClerkInstance()?.session?.getToken();
🤖 Prompt for AI Agents
In .changeset/tame-carpets-sink.md around line 22, the code calls getClerkInstance().session without guarding against getClerkInstance() returning undefined; change the access to use optional chaining (e.g., getClerkInstance()?.session?.getToken()) so you don't dereference undefined, and ensure the surrounding logic handles a potentially undefined token return. 
Comment on lines +30 to +33
const clerkInstance = getClerkInstance({ publishableKey: 'pk_xxx' });

// Use the instance outside of React
const token = await clerkInstance.session?.getToken();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Handle potential undefined from getClerkInstance().

On web, getClerkInstance() ignores the publishableKey parameter and returns window.Clerk, which may be undefined. Add optional chaining:

 const clerkInstance = getClerkInstance({ publishableKey: 'pk_xxx' }); // Use the instance outside of React -const token = await clerkInstance.session?.getToken(); +const token = await clerkInstance?.session?.getToken();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const clerkInstance = getClerkInstance({ publishableKey: 'pk_xxx' });
// Use the instance outside of React
const token = await clerkInstance.session?.getToken();
const clerkInstance = getClerkInstance({ publishableKey: 'pk_xxx' });
// Use the instance outside of React
const token = await clerkInstance?.session?.getToken();
🤖 Prompt for AI Agents
.changeset/tame-carpets-sink.md around lines 30 to 33: getClerkInstance may return undefined in web builds (window.Clerk), so calling .session or .getToken on the result can throw; update the usage to guard against undefined by using optional chaining when accessing the instance and its session (e.g., await clerkInstance?.session?.getToken()) so the code safely returns undefined if the Clerk instance or session is missing. 
@brkalow
Copy link
Member

brkalow commented Dec 20, 2025

@wobsoriano Thanks! At a minimum, can you add a change file to the upgrade package? Here: https://github.com/clerk/javascript/tree/main/packages/upgrade/src/versions/core-3/changes

@wobsoriano
Copy link
Member Author

!allow-major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants