feat(shared): Remove SWR
Description
Fixes: USER-4034
Checklist
- [ ]
pnpm testruns as expected. - [ ]
pnpm buildruns 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
-
Refactor
- Consolidated data-fetching onto React Query by replacing compatibility layers and virtual re-exports with concrete hook implementations and removing SWR variants.
-
Chores
- Promoted React Query core to a runtime dependency, removed SWR and environment-based switch flags, and simplified build/test configs.
-
Tests
- Simplified tests by removing environment branching and standardizing expectations across runs.
βοΈ Tip: You can customize this high-level summary in your review settings.
π¦ Changeset detected
Latest commit: ca5169065554de8cc4076471db16fdae7d8bfc24
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 19 packages
| Name | Type |
|---|---|
| @clerk/shared | Major |
| @clerk/agent-toolkit | Patch |
| @clerk/astro | Patch |
| @clerk/backend | Patch |
| @clerk/chrome-extension | Patch |
| @clerk/clerk-js | Patch |
| @clerk/expo-passkeys | Patch |
| @clerk/expo | Patch |
| @clerk/express | Patch |
| @clerk/fastify | Patch |
| @clerk/localizations | Patch |
| @clerk/nextjs | Patch |
| @clerk/nuxt | Patch |
| @clerk/react-router | Patch |
| @clerk/react | Patch |
| @clerk/tanstack-react-start | Patch |
| @clerk/testing | Patch |
| @clerk/ui | Patch |
| @clerk/vue | Patch |
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
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Review | Updated (UTC) |
|---|---|---|---|
| clerk-js-sandbox | Preview, Comment | Dec 18, 2025 4:07am |
π Walkthrough
Walkthrough
This PR removes SWR variants and the environment-based switchover, consolidating React Query implementations as the single data-fetching layer. It promotes @tanstack/query-core to a runtime dependency, deletes virtual-data-hooks declarations and HookAliasPlugin-based resolution, removes SWR re-exports and compatibility adapters, and updates tests and configs to no longer reference the CLERK_USE_RQ flag.
Changes
| Cohort / File(s) | Summary |
|---|---|
| Dependency & changeset | Promotes @tanstack/query-core to runtime dependencies (updated version in packages/shared and packages/clerk-js), removes swr from shared deps, and adds a changeset documenting removal of SWR switches. |
| Global types & virtual modules | Removes ambient __CLERK_USE_RQ__ declaration and deletes the virtual:data-hooks/* type module. |
| Build & test config | Removes HookAliasPlugin and virtual:data-hooks path aliases from tsconfig and tooling, simplifies path mappings, and stops initializing the __CLERK_USE_RQ__ global in test setup. |
| SWR adapter removal | Deletes the clerk-swr adapter that re-exported SWR APIs. |
| Billing hooks | Removes .swr.* variants, deletes some *.rq.* files, and replaces virtual re-exports with concrete React Query-based implementations (e.g., useInitializePaymentMethod, useStripeClerkLibs, useStripeLoader) or deletes deprecated exports. |
| Core hooks | Removes SWR implementations and virtual-module indirections, replacing many hooks with in-file React Query implementations (e.g., usePagesOrInfinite, useSubscription, usePlanDetailsQuery, usePaymentAttemptQuery, useStatementQuery) or removing obsolete exports. |
| Providers | Removes SWR-based SWRConfigCompat implementations and adds a simple passthrough component implementation (no SWR behavior). |
| Hook utilities & cache keys | Removes __CLERK_USE_RQ__-driven branches (e.g., _orgId variant) and updates internal comments to reflect a React Query-only approach. |
| Tests | Eliminates runtime branching on __CLERK_USE_RQ__ across tests and standardizes assertions to the React Query behavior. |
Pre-merge checks
β Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'feat(shared): Remove SWR' clearly and concisely summarizes the primary change in the changeset, which is the removal of SWR infrastructure. |
| Linked Issues check | β Passed | All coding requirements from USER-4034 are met: SWR files deleted, RQ files renamed, clerk-swr removed, plugins eliminated, SWR dependency removed, and @tanstack/query-core promoted to dependency. |
| Out of Scope Changes check | β Passed | All changes are directly related to the SWR removal objective. The package.json bump for @tanstack/query-core is part of the core requirement. |
| Docstring Coverage | β Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
π 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 b55dc0e0ac77cd89b769d9c60508f58aaa56cd74 and ca5169065554de8cc4076471db16fdae7d8bfc24.
β Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
π Files selected for processing (2)
packages/clerk-js/package.json(1 hunks)packages/shared/package.json(1 hunks)
π§ Files skipped from review as they are similar to previous changes (1)
- packages/clerk-js/package.json
π§° Additional context used
π Path-based instructions (5)
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
π CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/shared/package.json
packages/*/package.json
π CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/*/package.json: Packages should export TypeScript types alongside runtime code Follow semantic versioning for all packagesAll packages must be published under @clerk namespace
packages/*/package.json: Framework packages should depend on@clerk/clerk-jsfor core functionality@clerk/sharedshould be a common dependency for most packages in the monorepo
Files:
packages/shared/package.json
**/package.json
π CodeRabbit inference engine (.cursor/rules/global.mdc)
Use pnpm as the package manager for this monorepo
Files:
packages/shared/package.json
**/*.{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/shared/package.json
**/*
βοΈ 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/shared/package.json
β° 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 (billing, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- 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 (billing, chrome, RQ)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 16)
- GitHub Check: Integration Tests (quickstart, chrome, 16)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
Comment @coderabbitai help to get the list of available commands and usage tips.
@clerk/agent-toolkit
npm i https://pkg.pr.new/@clerk/agent-toolkit@7455
@clerk/astro
npm i https://pkg.pr.new/@clerk/astro@7455
@clerk/backend
npm i https://pkg.pr.new/@clerk/backend@7455
@clerk/chrome-extension
npm i https://pkg.pr.new/@clerk/chrome-extension@7455
@clerk/clerk-js
npm i https://pkg.pr.new/@clerk/clerk-js@7455
@clerk/dev-cli
npm i https://pkg.pr.new/@clerk/dev-cli@7455
@clerk/expo
npm i https://pkg.pr.new/@clerk/expo@7455
@clerk/expo-passkeys
npm i https://pkg.pr.new/@clerk/expo-passkeys@7455
@clerk/express
npm i https://pkg.pr.new/@clerk/express@7455
@clerk/fastify
npm i https://pkg.pr.new/@clerk/fastify@7455
@clerk/localizations
npm i https://pkg.pr.new/@clerk/localizations@7455
@clerk/nextjs
npm i https://pkg.pr.new/@clerk/nextjs@7455
@clerk/nuxt
npm i https://pkg.pr.new/@clerk/nuxt@7455
@clerk/react
npm i https://pkg.pr.new/@clerk/react@7455
@clerk/react-router
npm i https://pkg.pr.new/@clerk/react-router@7455
@clerk/shared
npm i https://pkg.pr.new/@clerk/shared@7455
@clerk/tanstack-react-start
npm i https://pkg.pr.new/@clerk/tanstack-react-start@7455
@clerk/testing
npm i https://pkg.pr.new/@clerk/testing@7455
@clerk/ui
npm i https://pkg.pr.new/@clerk/ui@7455
@clerk/upgrade
npm i https://pkg.pr.new/@clerk/upgrade@7455
@clerk/vue
npm i https://pkg.pr.new/@clerk/vue@7455
commit: ca51690
We've found a few last outstanding bugs in the RQ implementation so I think we should hold this until we've fixed those. I've pinged you elsewhere with details @jacekradko. π