---
title: Customize the React SDK error handler
slug: feature-experimentation/docs/customize-error-handler-for-the-react-sdk
docTags: 
createdAt: 2026-08-05T20:39:59.000Z
---

In a production environment, you should have full control and visibility over the errors that are happening in your application, including those that would originate from an Optimizely SDK.

## Minimum SDK version

v4.0.0+

For versions 3.x and earlier, see [React SDK prior to v4](docId:7l7bR22AwvR6ySSsF3Mgq).

In v4, error handling uses the `createErrorNotifier` factory function. The `errorHandler` parameter on `createInstance` from v3 is replaced.

## Configure error handling

Use `createErrorNotifier` to create an error notifier and pass it to `createInstance`:

```javascript
import {
  createInstance,
  createPollingProjectConfigManager,
  createErrorNotifier,
} from '@optimizely/react-sdk';

const errorNotifier = createErrorNotifier({
  handleError: (error) => {
    console.error('CUSTOM_ERROR_HANDLER');
    console.error(`Error Message: ${error.message}`);
    console.error(`Error Stack: ${error.stack}`);
  },
});

const optimizely = createInstance({
  projectConfigManager: createPollingProjectConfigManager({
    sdkKey: 'YOUR_SDK_KEY',
  }),
  errorNotifier,
});
```

## Default behavior

If no `errorNotifier` is passed to `createInstance`, error notification is disabled (no-op handler).
