Skip to main content
Learn how to integrate Entri into your React application with proper event handling and state management.

Prerequisites

  • Your applicationId from the Entri dashboard
  • A valid JWT token fetched from your server
  • Basic understanding of React hooks

Installation

Import the functions you need:
NPM functions are async - the package automatically loads the Entri SDK when first called.

Quick Start (NPM)

Custom Hook (NPM)

With TypeScript (NPM)

The package exports types you can use:

Using the Hook

Once you have the hook, use it in your components:

Event Handling

Entri emits events via window. Set up listeners in useEffect before calling showEntri().
Events work the same way for both NPM and Script Tag installations.

onSuccess

Triggered when the user successfully completes domain setup.

onEntriClose

Triggered when the modal is closed, whether successful or not.

onEntriStepChange

Triggered when the user moves between screens. Useful for analytics.

onEntriManualSetupDocumentationClick

Triggered when the user clicks the manual setup guide link.

Troubleshooting

Event listeners not firing

Make sure you’re adding listeners before calling showEntri(). In React, use useEffect to set up listeners on mount:

Stale state in event handlers

React’s closures can capture stale state. Use refs or functional updates:

Multiple event handlers firing

Ensure you clean up listeners when the component unmounts:

Focus Trap Conflicts

When using Entri with React UI libraries that implement their own focus management (Reach UI Dialog, Radix UI), you may experience focus conflicts where tab navigation breaks.

The Problem

Both Entri and your modal library compete for focus control. Common symptoms:
  • Tab key not cycling through elements correctly
  • Focus jumping unexpectedly
  • Screen reader navigation issues
Mount Entri inside your existing dialog using embedded mode:

Solution 2: Disable Focus Lock When Entri is Active

Use a state flag to disable your focus trap while Entri is open:
This issue has been observed with Reach UI Dialog specifically, but may occur with other libraries that implement aggressive focus locking.

Next Steps