Skip to main content
React apps need a bit more care around script loading and cleanup. The patterns below handle all of it correctly.

Basic pattern — useEffect

The simplest approach: load the SDK script and init once on mount.
The cleanup function window.EPIS?.unmount('#epis-chat') runs when the component unmounts — preventing iframe leaks if the user navigates away and back.

Custom hook — reusable across your app

Extract the logic into a hook so any component can mount EPIS:

Next.js — App Router

Use a Client Component with dynamic import to avoid SSR issues:

Handling auth events in React

TypeScript types

Add these declarations to avoid window.EPIS type errors: