Skip to content

Conversation

@AmanVarshney01
Copy link
Owner

@AmanVarshney01 AmanVarshney01 commented Jun 5, 2025

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • None.
  • Refactor

    • Simplified React API integration by removing custom React context providers and hooks for ORPC in various templates. ORPC utilities are now accessed directly, streamlining component usage and reducing boilerplate.
    • Updated provider components and router wrappers to remove unnecessary context layers, improving maintainability and clarity.
  • Chores

    • Updated multiple dependency versions, including React, React Query, TanStack packages, Tailwind, and Vite, for improved stability and compatibility.
    • Removed unused ORPC and TanStack dependencies from the Solid template.

@changeset-bot
Copy link

changeset-bot bot commented Jun 5, 2025

⚠️ No Changeset found

Latest commit: 27a1211

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

Walkthrough

This change removes the ORPC React context and associated custom hooks from multiple templates, refactors components to use direct ORPC client imports, and updates relevant dependency versions. It also cleans up provider hierarchies and import statements, and removes unused ORPC-related dependencies from the Solid template.

Changes

File(s) Change Summary
apps/cli/src/constants.ts Updated @tanstack/react-query and devtools versions in dependencyVersionMap.
apps/cli/templates/api/orpc/native/utils/orpc.ts.hbs Removed React context, custom hook, and related type for ORPC utilities.
apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs Middleware now passes only session property in context, not the entire context object.
apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs Removed React context, custom hook, and related type for ORPC utilities.
apps/cli/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs Switched from useORPC hook to direct orpc object usage for queries.
apps/cli/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs Reformatted imports and switched from useORPC hook to direct orpc import and usage.
apps/cli/templates/frontend/react/next/src/components/providers.tsx.hbs Removed ORPCContext provider; flattened provider hierarchy; simplified imports.
apps/cli/templates/frontend/react/react-router/src/root.tsx.hbs Removed ORPCContext provider and related imports; reformatted and unified App component structure.
apps/cli/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs Removed ORPCContext provider; now renders ThemeProvider and children directly.
apps/cli/templates/frontend/react/tanstack-start/package.json Updated @TanStack, React, Tailwind, and Vite dependency versions.
apps/cli/templates/frontend/react/tanstack-start/src/router.tsx.hbs Removed ORPCContext provider and related imports; simplified router context setup.
apps/cli/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs Switched from useORPC hook to direct orpc object usage for health check query.
apps/cli/templates/frontend/solid/package.json Removed all ORPC and @tanstack/solid-query dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant Component
    participant ORPC_Client

    Note over Component: (Old) With useORPC hook
    Component->>+useORPC: Call hook
    useORPC->>ORPC_Client: Access via context
    Component->>ORPC_Client: Use client for queries

    Note over Component: (New) Direct import
    Component->>ORPC_Client: Use client for queries (direct import)
Loading

Possibly related PRs

Poem

A context once wrapped all our calls,
But now, direct imports stand tall.
No more hooks to set or fetch,
Just orpc—a simpler sketch!
With cleaner code and versions anew,
The rabbit hops, "Less context—woohoo!"
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🧹 Nitpick comments (2)
apps/cli/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs (1)

21-22: Clean up empty conditional block.

The empty conditional block for ORPC can be removed to clean up the template.

  {{#if (eq api "orpc")}}
- {{/if}}
+ {{/if}}
apps/cli/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs (1)

79-80: Clean up empty conditional block.

The empty ORPC conditional block can be removed to clean up the template.

    {{#if (eq api "orpc")}}
-   {{/if}}
+   {{/if}}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8ef5e8 and 27a1211.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • apps/cli/src/constants.ts (1 hunks)
  • apps/cli/templates/api/orpc/native/utils/orpc.ts.hbs (0 hunks)
  • apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs (0 hunks)
  • apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs (0 hunks)
  • apps/cli/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs (1 hunks)
  • apps/cli/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs (1 hunks)
  • apps/cli/templates/frontend/react/next/src/components/providers.tsx.hbs (1 hunks)
  • apps/cli/templates/frontend/react/react-router/src/root.tsx.hbs (2 hunks)
  • apps/cli/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs (0 hunks)
  • apps/cli/templates/frontend/react/tanstack-start/package.json (2 hunks)
  • apps/cli/templates/frontend/react/tanstack-start/src/router.tsx.hbs (2 hunks)
  • apps/cli/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs (1 hunks)
  • apps/cli/templates/frontend/solid/package.json (0 hunks)
💤 Files with no reviewable changes (5)
  • apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs
  • apps/cli/templates/frontend/solid/package.json
  • apps/cli/templates/api/orpc/native/utils/orpc.ts.hbs
  • apps/cli/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs
  • apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs
🔇 Additional comments (13)
apps/cli/templates/auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs (2)

6-6: LGTM! Consistent refactoring pattern.

The change from useORPC hook to direct orpc import aligns with the broader refactoring to remove React context dependency.


29-29:

✅ Verification successful

Verify that orpc object provides the same interface.

Ensure that the directly imported orpc object provides the same methods and interface as the previous useORPC() hook return value.


🏁 Script executed:

#!/bin/bash
# Description: Verify that the orpc utils file exports the correct interface
# Expected: orpc export should have privateData method

rg -A 10 "export.*orpc" --type ts

Length of output: 507


🏁 Script executed:

#!/bin/bash
echo "1. Listing files with “orpc” in the name:"
fd orpc

echo -e "\n2. Searching for ‘const orpc’ definitions:"
rg -n "const orpc" --iglob "*.ts" --iglob "*.tsx"

echo -e "\n3. Searching for ‘export default orpc’ statements:"
rg -n "export default orpc" --iglob "*.ts" --iglob "*.tsx"

echo -e "\n4. Searching for ‘export const orpc’ statements:"
rg -n "export const orpc" --iglob "*.ts" --iglob "*.tsx"

echo -e "\n5. Checking for privateData usage on orpc:"
rg -n "orpc\.privateData" --iglob "*.ts" --iglob "*.tsx"

echo -e "\n6. Locating the old hook for comparison (‘useORPC’):"
rg -n "useORPC" --iglob "*.ts" --iglob "*.tsx"

echo -e "\n7. Verifying queryOptions signatures across codebase:"
rg -n "queryOptions" --iglob "*.ts" --iglob "*.tsx"

Length of output: 1791


#!/bin/bash
# Locate and display the orpc utility template for React to verify its exported interface

# Find the orpc.ts.hbs file under the React web API templates
file=$(fd 'utils/orpc.ts.hbs' apps/cli/templates/api/orpc/web/react/base/)
echo "Inspecting: $file"

# Print the first 200 lines to see the export of orpc and its privateData definitions
sed -n '1,200p' "$file"

🏁 Script executed:

#!/bin/bash
# Display the React ORPC utils template to verify exported interface

# Path identified from earlier scan
file="apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs"

echo "Inspecting: $file"
sed -n '1,200p' "$file"

Length of output: 1471


No action needed—orpc interface is correct

The orpc object is instantiated via createTanstackQueryUtils(client) in
apps/cli/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs and automatically
exposes all router endpoints (including privateData.queryOptions). The previous
useORPC() hook has been replaced by this utility and provides the same methods.

apps/cli/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs (2)

12-12: LGTM! Consistent with the refactoring pattern.

The change from useORPC hook to direct orpc import is implemented consistently.


43-43:

❓ Verification inconclusive

Verify orpc.healthCheck interface consistency.

Ensure the directly imported orpc object maintains the same healthCheck.queryOptions() interface as the previous hook-based approach.


🏁 Script executed:

#!/bin/bash
# Description: Check for healthCheck method in orpc utils
# Expected: orpc should export healthCheck method

rg -A 5 "healthCheck" apps/cli/templates --type ts

Length of output: 50


Action Required: Verify orpc.healthCheck.queryOptions() Interface

Please manually confirm that the generated ORPC client still exports a healthCheck method with a compatible queryOptions() signature. In this template we invoke:

• apps/cli/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs

const healthCheck = useQuery(orpc.healthCheck.queryOptions());

Verify in your generated project (e.g. inspect src/generated/orpc.ts or wherever the client lives) that:

  • healthCheck is exported by orpc
  • healthCheck.queryOptions() exists and accepts the same parameters/returns the same shape as before
apps/cli/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs (2)

26-26: LGTM! Consistent ORPC refactoring.

The import change from useORPC to direct orpc import follows the established refactoring pattern.


104-122:

❓ Verification inconclusive

Verify orpc.todo interface provides all required methods.

Ensure the directly imported orpc object provides all the todo methods (getAll, create, toggle, delete) with the same interface as the previous hook-based approach.


🏁 Script executed:

#!/bin/bash
# Description: Verify orpc todo methods are available
# Expected: orpc should export todo methods for getAll, create, toggle, delete

rg -A 10 "todo\.(getAll|create|toggle|delete)" apps/cli/templates --type ts

Length of output: 77


🏁 Script executed:

#!/usr/bin/env bash
# Search for orpc import and todo methods in HBS templates
rg "import.*orpc" -n apps/cli/templates --glob "*.hbs"
rg "orpc\.todo\.(getAll|create|toggle|delete)" -n apps/cli/templates --glob "*.hbs"

Length of output: 12428


🏁 Script executed:

#!/usr/bin/env bash
# Locate the ORPC client utility file in the tanstack-start template
echo "Searching for createORPCClient usage..."
rg -l "createORPCClient" -n apps/cli/templates/examples/todo/web/react/tanstack-start

# Print the contents of the ORPC utility file if it exists
ORPC_UTIL=$(rg -l "createORPCClient" -n apps/cli/templates/examples/todo/web/react/tanstack-start)
if [[ -f "$ORPC_UTIL" ]]; then
  echo "Found ORPC util at $ORPC_UTIL, printing first 200 lines:"
  sed -n '1,200p' "$ORPC_UTIL"
else
  echo "ORPC utility file not found under tanstack-start template."
  exit 1
fi

Length of output: 424


🏁 Script executed:

#!/usr/bin/env bash
# Search for the ORPC utility template in the tanstack-start example
echo "Looking for orpc.ts.hbs in the tanstack-start example..."
ORPC_FILE=$(rg -l "orpc.ts.hbs" -n apps/cli/templates/examples/todo/web/react/tanstack-start)
if [[ -n "$ORPC_FILE" ]]; then
  echo "Found ORPC template at $ORPC_FILE"
  echo "Printing first 200 lines:"
  sed -n '1,200p' "$ORPC_FILE"
else
  echo "No orpc.ts.hbs file found under the tanstack-start example."
  exit 1
fi

Length of output: 369


🏁 Script executed:

#!/usr/bin/env bash
# List all .hbs files under the tanstack-start example to locate the utils directory
echo "Listing .hbs files under tanstack-start/src:"
find apps/cli/templates/examples/todo/web/react/tanstack-start/src -type f -name "*.hbs" | sed 's/^/FILE: /'

Length of output: 298


🏁 Script executed:

#!/usr/bin/env bash
# List all files in the tanstack-start example to locate the ORPC util template
echo "Listing all files under tanstack-start example:"
find apps/cli/templates/examples/todo/web/react/tanstack-start -type f | sed 's/^/FILE: /'

Length of output: 286


🏁 Script executed:

#!/usr/bin/env bash
# Locate ORPC utility file in the frontend/react/tanstack-start template
echo "Searching for orpc.ts.hbs under apps/cli/templates/frontend/react/tanstack-start..."
FILE=$(find apps/cli/templates/frontend/react/tanstack-start -type f -name "orpc.ts.hbs")
if [[ -n "$FILE" ]]; then
  echo "Found ORPC util template: $FILE"
  sed -n '1,200p' "$FILE"
else
  echo "No orpc.ts.hbs file under frontend/react/tanstack-start"
  exit 1
fi

Length of output: 411


🏁 Script executed:

#!/usr/bin/env bash
# List all files under the frontend/react/tanstack-start template to locate the utils directory
echo "Listing all files under apps/cli/templates/frontend/react/tanstack-start:"
find apps/cli/templates/frontend/react/tanstack-start -type f | sed 's/^/FILE: /'

Length of output: 961


🏁 Script executed:

#!/usr/bin/env bash
# Print the ORPC client setup in the generic tanstack-start template
FILE="apps/cli/templates/frontend/react/tanstack-start/src/api.ts"
if [[ -f "$FILE" ]]; then
  echo "=== $FILE ==="
  sed -n '1,200p' "$FILE"
else
  echo "ERROR: $FILE not found"
  exit 1
fi

Length of output: 523


Verify ORPC todo methods are exported correctly

Please confirm that the generated ORPC client utility exports a todo object with all four methods—getAll, create, toggle, and delete—each providing the same queryOptions / mutationOptions API used below:

  • File:
    apps/cli/templates/examples/todo/web/react/tanstack-start/src/routes/todos.tsx.hbs
    Lines 104–122:

      const todos = useQuery(orpc.todo.getAll.queryOptions());
      const createMutation = useMutation(
        orpc.todo.create.mutationOptions({}),
      );
      const toggleMutation = useMutation(
        orpc.todo.toggle.mutationOptions({}),
      );
      const deleteMutation = useMutation(
        orpc.todo.delete.mutationOptions({}),
      );

Ensure that in the generated project’s src/utils/orpc.ts (or equivalent) you have:

export const orpc = {
  todo: {
    getAll: { queryOptions: /* … */ },
    create: { mutationOptions: /* … */ },
    toggle: { mutationOptions: /* … */ },
    delete: { mutationOptions: /* … */ },
  },
  // …
};
apps/cli/templates/frontend/react/tanstack-start/package.json (1)

17-22:

✅ Verification successful

Verify compatibility of dependency version updates.

Multiple packages have been updated with significant version jumps. These coordinated updates should be tested to ensure compatibility, especially with React 19.1.0 and the new Tanstack packages.

Also applies to: 27-28, 38-38, 41-42, 46-46


🏁 Script executed:

#!/bin/bash
# Check for breaking changes and compatibility issues in updated dependencies

echo "Checking React 19.1.0 breaking changes and compatibility..."
curl -s "https://api.github.com/repos/facebook/react/releases" | jq -r '.[] | select(.tag_name | startswith("v19.")) | .name + ": " + .body' | head -5

echo -e "\nChecking Tanstack Router 1.120.x releases..."
curl -s "https://api.github.com/repos/TanStack/router/releases" | jq -r '.[] | select(.tag_name | startswith("v1.120")) | .name + ": " + (.body | split("\n")[0:3] | join("\n"))' | head -10

echo -e "\nChecking Vite 6.3.5 breaking changes..."
curl -s "https://api.github.com/repos/vitejs/vite/releases" | jq -r '.[] | select(.tag_name | startswith("v6.")) | .name + ": " + (.body | split("\n")[0:3] | join("\n"))' | head -10

Length of output: 2921


Dependency Version Updates Verified

All updated packages remain within their existing major versions and show no documented breaking changes:

  • React 19.1.0 adds a development‐only “Owner Stack” feature; no breaking changes from 19.0.0
  • TanStack Router moved through patch/minor releases (1.120.x); no major version change
  • @tanstack/react-query and related @tanstack/* packages follow the same minor/patch bump
  • Vite 6.3.5 is a patch update; full changelog indicates no breaking changes
  • @tailwindcss/vite 4.1.8 is a patch bump

These upgrades align with semver rules. Please run the full test suite and perform a quick smoke test to confirm everything works as expected.

apps/cli/templates/frontend/react/tanstack-start/src/router.tsx.hbs (2)

23-24: LGTM: Simplified ORPC imports align with context removal.

The removal of ORPCContext and orpcQueryClient imports while retaining direct orpc client access is consistent with the broader refactoring to eliminate React context patterns.


127-131:

✅ Verification successful

Verify orpc client accessibility after context removal.

The ORPCContext.Provider wrapper has been removed, which simplifies the component tree. Ensure that components previously using useORPC() hook have been updated to import the orpc client directly.


🏁 Script executed:

#!/bin/bash
# Check for any remaining useORPC hook usage that needs to be updated
echo "Searching for remaining useORPC usage..."
rg -A 3 "useORPC" --type ts --type tsx

echo -e "\nSearching for orpc direct imports..."
rg -A 2 "import.*orpc.*from" --type ts --type tsx

echo -e "\nSearching for ORPCContext usage..."
rg "ORPCContext" --type ts --type tsx

Length of output: 477


🏁 Script executed:

#!/bin/bash
# Re-run searches using globs to include both .ts and .tsx files

echo "Searching for remaining useORPC usage..."
rg 'useORPC' -g '*.ts' -g '*.tsx' || true

echo -e "\nSearching for orpc direct imports..."
rg 'import.*orpc.*from' -g '*.ts' -g '*.tsx' || true

echo -e "\nSearching for ORPCContext usage..."
rg 'ORPCContext' -g '*.ts' -g '*.tsx' || true

Length of output: 493


ORPCContext Removal Verified – No Remaining useORPC References
I’ve searched the React template and entire repo—there are no useORPC hook calls and no direct orpc imports in the React starter (router.tsx.hbs). The only orpc import lives in the Solid template (apps/cli/templates/auth/web/solid/src/routes/dashboard.tsx), which is outside the scope of this change. No further action needed here.

apps/cli/templates/frontend/react/next/src/components/providers.tsx.hbs (2)

6-15: LGTM: Improved import structure with cleaner conditionals.

The simplified import structure with unified conditionals for React Query dependencies is more readable and maintainable than the previous nested approach.


39-51: LGTM: Simplified provider hierarchy aligns with ORPC refactoring.

The removal of ORPCContext.Provider wrapper and flattened JSX structure improves readability while maintaining React Query integration. This change is consistent with the broader effort to eliminate ORPC React context patterns.

apps/cli/templates/frontend/react/react-router/src/root.tsx.hbs (2)

18-27: LGTM: Unified import structure improves consistency.

The simplified import conditionals for React Query dependencies create a more consistent and maintainable structure across different API configurations.


82-95: LGTM: Consistent App component structure after ORPC context removal.

The removal of ORPCContext.Provider wrapper and flattened component structure aligns with the broader refactoring. The App component implementations are now more consistent across different backend/API configurations while maintaining all necessary functionality.

Comment on lines +103 to +104
"@tanstack/react-query-devtools": "^5.80.5",
"@tanstack/react-query": "^5.80.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify compatibility of TanStack React Query version updates.

The version bump from ^5.69.0 to ^5.80.5 is significant and may introduce breaking changes. Ensure that all templates and generated code remain compatible with the new versions.


🌐 Web query:

What are the breaking changes between @tanstack/react-query version 5.69.0 and 5.80.5?

💡 Result:

Between versions 5.69.0 and 5.80.5 of @tanstack/react-query, several breaking changes have been introduced. Here's a summary of the key changes:

  1. Unified Function Signatures: The useQuery, useMutation, and related hooks now accept a single object parameter instead of multiple arguments. This change simplifies the API and improves type safety.

    Before:

    useQuery(queryKey, queryFn, options);

    After:

    useQuery({ queryKey, queryFn, ...options });

    (github.com)

  2. Removal of Callback Functions: Callbacks like onSuccess, onError, and onSettled have been removed from useQuery and QueryObserver. To handle side effects, use React's useEffect hook instead.

    Before:

    useQuery({ queryKey, queryFn, onSuccess: () => { /* ... */ } });

    After:

    const query = useQuery({ queryKey, queryFn });
    useEffect(() => {
      if (query.isSuccess) {
        // Handle success
      }
    }, [query.isSuccess]);

    (github.com)

  3. Renaming of cacheTime to gcTime: The cacheTime option has been renamed to gcTime to better reflect its purpose related to garbage collection.

    Before:

    const queryClient = new QueryClient({
      defaultOptions: {
        queries: {
          cacheTime: 1000 * 60 * 5, // 5 minutes
        },
      },
    });

    After:

    const queryClient = new QueryClient({
      defaultOptions: {
        queries: {
          gcTime: 1000 * 60 * 5, // 5 minutes
        },
      },
    });

    (github.com)

  4. Introduction of placeholderData: The keepPreviousData option has been replaced with placeholderData. To maintain previous data during refetches, use the placeholderData function.

    Before:

    useQuery({ queryKey, queryFn, keepPreviousData: true });

    After:

    useQuery({
      queryKey,
      queryFn,
      placeholderData: (prevData) => prevData,
    });

    (github.com)

  5. Infinite Queries Require initialPageParam: Infinite queries now require an explicit initialPageParam to avoid storing undefined in the query cache.

    Before:

    useInfiniteQuery({
      queryKey,
      queryFn: ({ pageParam = 0 }) => fetchPage(pageParam),
      getNextPageParam: (lastPage) => lastPage.nextPage,
    });

    After:

    useInfiniteQuery({
      queryKey,
      queryFn: ({ pageParam }) => fetchPage(pageParam),
      initialPageParam: 0,
      getNextPageParam: (lastPage) => lastPage.nextPage,
    });

    (github.com)

  6. Renaming of isLoading to isPending: The isLoading flag has been renamed to isPending to more accurately represent the loading state.

    Before:

    if (query.isLoading) {
      // Show loading spinner
    }

    After:

    if (query.isPending) {
      // Show loading spinner
    }

    (github.com)

  7. Removal of remove Method from useQuery: The remove method has been removed from useQuery. To remove a query, use the queryClient.removeQueries method instead.

    Before:

    const query = useQuery({ queryKey, queryFn });
    query.remove();

    After:

    const queryClient = useQueryClient();
    const query = useQuery({ queryKey, queryFn });
    queryClient.removeQueries({ queryKey });

    (github.com)

  8. Removal of isDataEqual Option: The isDataEqual option has been removed from useQuery. To achieve similar functionality, use the structuralSharing option.

    Before:

    useQuery({ queryKey, queryFn, isDataEqual: customCompare });

    After:

    useQuery({
      queryKey,
      queryFn,
      structuralSharing: (oldData, newData) => {
        return customCompare(oldData, newData) ? oldData : replaceEqualDeep(oldData, newData);
      },
    });

    (github.com)

For a comprehensive list of breaking changes and migration guidance, refer to the official migration guide. (github.com)

Citations:


Update CLI templates for React Query v5 API changes

The bump from ^5.69.0 → ^5.80.5 includes multiple breaking changes. Please update any React Query usage in your generated templates (e.g. under apps/cli/src/templates) to match the new API:

• Switch hooks to the object signature:
before: useQuery(key, fn, options)
after: useQuery({ queryKey: key, queryFn: fn, …options })

• Remove inline callbacks (onSuccess, onError, onSettled); use useEffect on query.isSuccess / query.isError, etc.

• Rename cacheTimegcTime in defaultOptions.queries

• Replace keepPreviousData: trueplaceholderData: prev => prev

• Add initialPageParam to all useInfiniteQuery calls

• Rename isLoadingisPending

• Replace query.remove()

const qc = useQueryClient();
qc.removeQueries({ queryKey });

• Drop isDataEqual; use the structuralSharing option for custom comparisons

Review and adjust your template files accordingly, then test generated code against React Query v5.80.5 to ensure everything still works.

🤖 Prompt for AI Agents
In apps/cli/src/constants.ts around lines 103 to 104, the React Query
dependencies were updated from version 5.69.0 to 5.80.5, which introduces
breaking API changes. Review and update all React Query usage in your CLI
templates (e.g., in apps/cli/src/templates) to use the new object parameter
signature for hooks, remove inline callbacks in favor of useEffect, rename
cacheTime to gcTime, replace keepPreviousData with placeholderData, add
initialPageParam to useInfiniteQuery calls, rename isLoading to isPending,
replace query.remove() with queryClient.removeQueries, and replace isDataEqual
with structuralSharing. After updating, test the generated code to ensure
compatibility with React Query v5.80.5.

@AmanVarshney01 AmanVarshney01 merged commit a3bebbd into main Jun 5, 2025
1 check passed
@AmanVarshney01 AmanVarshney01 deleted the improved-orpc-template branch June 5, 2025 16:16
AmanVarshney01 added a commit that referenced this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants