Skip to main content

Overview

The scan() function is the primary API for initializing React Scan. It starts the scanning process and applies the provided configuration options.

Signature

scan(options?: Options): void

Parameters

options
Options
default:"{}"
Optional configuration object to customize React Scan behavior. See Options for all available settings.

Returns

void - This function does not return a value.

Usage

Basic Usage

import { scan } from 'react-scan';

scan();

With Options

import { scan } from 'react-scan';

scan({
  enabled: true,
  showToolbar: true,
  log: false,
});

Development Only

import { scan } from 'react-scan';

scan({
  enabled: process.env.NODE_ENV === 'development',
});

Force Production Mode

import { scan } from 'react-scan';

scan({
  enabled: true,
  dangerouslyForceRunInProduction: true,
});
Using dangerouslyForceRunInProduction in production is not recommended as it can impact performance.

Behavior

  • If enabled is false and showToolbar is not explicitly true, React Scan will not initialize
  • React Scan will not run inside iframes unless allowInIframe is set to true
  • By default, React Scan only runs in development mode. Use dangerouslyForceRunInProduction to override this behavior

See Also

Build docs developers (and LLMs) love