javascript icon indicating copy to clipboard operation
javascript copied to clipboard

feat(shared): Remove SWR

Open jacekradko opened this issue 2 weeks ago β€’ 5 comments

Description

Fixes: USER-4034

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

  • 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.

jacekradko avatar Dec 14 '25 18:12 jacekradko

πŸ¦‹ 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

changeset-bot[bot] avatar Dec 14 '25 18:12 changeset-bot[bot]

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 18, 2025 4:07am

vercel[bot] avatar Dec 14 '25 18:12 vercel[bot]

πŸ“ 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.yaml is 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 packages

All packages must be published under @clerk namespace

packages/*/package.json: Framework packages should depend on @clerk/clerk-js for core functionality @clerk/shared should 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.

coderabbitai[bot] avatar Dec 14 '25 18:12 coderabbitai[bot]

Open in StackBlitz

@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

pkg-pr-new[bot] avatar Dec 14 '25 20:12 pkg-pr-new[bot]

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. πŸ˜„

Ephem avatar Dec 18 '25 12:12 Ephem