Skip to main content

Developer tools

Developer tools to make debugging easier when using React Navigation.

To use the developer tools, install @react-navigation/devtools:

npm install @react-navigation/devtools

Hooks from this package only work during development and are disabled in production. You don't need to do anything special to remove them from the production build.

API Definition​

The package exposes the following APIs:

useLogger​

This hook provides a logger for React Navigation. It logs the navigation state and actions to the console.

Usage:

To use the hook, import it and pass a ref to the NavigationContainer as its argument:

import * as React from 'react';
import {
createStaticNavigation,
useNavigationContainerRef,
} from '@react-navigation/native';
import { useLogger } from '@react-navigation/devtools';

/* content */

export default function App() {
const navigationRef = useNavigationContainerRef();

useLogger(navigationRef);

return <Navigation ref={navigationRef} />;
}

useReduxDevToolsExtension​

This hook provides integration with Redux DevTools Extension. It also works with React Native Debugger app which includes this extension.

Usage:

To use the hook, import it and pass a ref to the NavigationContainer as its argument:

import * as React from 'react';
import {
createStaticNavigation,
useNavigationContainerRef,
} from '@react-navigation/native';
import { useReduxDevToolsExtension } from '@react-navigation/devtools';

/* content */

export default function App() {
const navigationRef = useNavigationContainerRef();

useReduxDevToolsExtension(navigationRef);

return <Navigation ref={navigationRef} />;
}

Now, you'll be able to see logs from React Navigation in Redux DevTools Extension, e.g. when you're debugging your app with React Native Debugger app.