DEV Community

Cover image for React Query - DevTools
Luca Del Puppo for This is Learning

Posted on • Originally published at blog.delpuppo.net on

19

React Query - DevTools

Hey Folks,

In this post, you'll learn how to debug and check whatever happens in your React Query application. It's normal when you begin to learn or use a tool; check the tools around it to understand the developer experience so you can decide whether to continue with it. The React query team knows that and has decided to build a tool to help the developer that wants to work with React Query.

This tool is called react-query-devtools and you can install it in a simple step.

Open your terminal and type



$ npm i @tanstack/react-query-devtools


Enter fullscreen mode Exit fullscreen mode

Now, in your project, you can use it and get all the info required to debug your application.

This tool is simple to use. In your application, you must import it and render it where you render the ReactQueryProvider.



import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import React from "react";
import { queryClient } from './react-query/client';
import Router from './Router';

function App() {
  return (
    <React.StrictMode>
      <QueryClientProvider client={queryClient}>
        ...
        <ReactQueryDevtools />
      </QueryClientProvider>
    </React.StrictMode>
  );
}
export default App;


Enter fullscreen mode Exit fullscreen mode

Easy peasy, no?

With ReactQueryDevtools, you don't have to pay attention to the environment to render or not the component because it provides it by default. It renders the component only if the condition process.env.NODE_ENV === 'development' is true.

You can customize the component or force its render also in production mode if you want. To find out more about these topics, you can check the documentation.

The benefit of using this component in your application is that it allows seeing what happens in ReactQuery at runtime. You can check the data saved in the state, how many application parts use the different queries, etc. You can also reset the state or remove part of it to re-fetch the data.

Yeap, it exposes many good features to debug and check your React Query application, and it is a good tool for every developer that works with React Query. Here you can find an example of ReactQueryDevtool at work

Devtool view

If you want to find out more, watch my Youtube video about React Query Devtool to see it in action.

Ok, that's all! I think you have an idea of what React Query Devtools is and how you can integrate it into your application!

I hope you enjoyed this content!

See you soon folks
Bye Bye 👋

p.s. you can find the code of the video here

Photo by Rahul Mishra on Unsplash

Heroku

Amplify your impact where it matters most — building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup 🚀

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay