Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-query-devtools

tannerlinsley70.7kMIT2.6.3TypeScript support: included

Devtools for React Query

readme

React Query Devtools Header

Devtools for React Query

#TanStack Join the community on Spectrum

Enjoy this library? Try them all! React Query, React Table, React Form, React Charts

Quick Features

  • View the cache in realtime
  • Inspect core query objects and query data payloads
  • Manually refetch & remove queries

Demo

Documentation

Installation

$ npm i --save react-query-devtools
# or
$ yarn add react-query-devtools

Using React Native? Try react-query-native-devtools instead.

Usage

By default, React Query Devtools are not imported and used when process.env.NODE_ENV === 'production', so you don't need to worry about excluding them during a production build.

If you want to use the devtools in production, you can manually import them (preferably asynchronously code-split) by importing the dist/react-query-devtools.production.min.js file directly.

Floating Mode

Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.

Place the following code as high in your React app as you can. The closer it is to the root of the page, the better it will work!

import { ReactQueryDevtools } from 'react-query-devtools'

function App() {
  return (
    <>
      {/* The rest of your application */}
      <ReactQueryDevtools initialIsOpen={false} />
    </>
  )
}

Options

  • initialIsOpen: Boolean
    • Set this true if you want the dev tools to default to being open
  • panelProps: PropsObject
    • Use this to add props to the panel. For example, you can add className, style (merge and override default style), etc.
  • closeButtonProps: PropsObject
    • Use this to add props to the close button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
  • toggleButtonProps: PropsObject
    • Use this to add props to the toggle button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
  • position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"
    • Defaults to bottom-left
    • The position of the React Query logo to open and close the devtools panel

Embedded Mode

Embedded Mode will embed the devtools as a regular component in your application. You can style it however you'd like after that!

import { ReactQueryDevtoolsPanel } from 'react-query-devtools'

function App() {
  return (
    <>
      {/* The rest of your application */}
      <ReactQueryDevtoolsPanel style={styles} className={className} />
    </>
  )
}

Options

Use these options to style the dev tools.

  • style: StyleObject
    • The standard React style object used to style a component with inline styles
  • className: string
    • The standard React className property used to style a component with classes

changelog

Changelog

1.1.5

  • Added default styles for inputs and select boxes
  • Fixed a bug where match-sorter was not a dependency

1.1.4

  • Added the ability to filter the query list

1.1.2 - 1.1.3

  • Updated the global package namespace from ReactQuery to ReactQueryDevtools

1.1.1

  • Fixed an issue where arrow functions were present in the production placeholder build

1.1.0

  • Added the ability to add props to all three internal dev tools components
  • Fixed an issue where z-index was not initially set to something very high

1.0.13

  • Better overflow styles
  • No more useLayoutEffect warnings in non-window environments like Next.js

1.0.12

  • Prevent queries header from scrolling

1.0.11

  • No text shadow on stale indicators

1.0.10

  • Fix instance count styles

1.0.9

  • Default sort by status
  • Add instance count next to query

1.0.8

  • Sort by status is now fixed for fresh queries

1.0.7

  • Buttons now use a pointer cursor style

1.0.6

  • Removes Codemirror Editing until a non-css-file based solution can be found

1.0.5

  • Fixes an issue where localStorage could not be accessed and would crash
  • Removes some stray logging

1.0.4

  • Fix: Devtools will import noop components during production by default. Updated Readme with information on how to use in production as well.

1.0.3

  • Styles: Toggle button has less of a text-shadow now

1.0.2

Initial Release!