Created
September 26, 2025 22:48
-
-
Save sduquej/793b109a00ec5c9438641b4f48252e84 to your computer and use it in GitHub Desktop.
client component to open Intercom messenger in new message view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; | |
| import { useEffect } from "react"; | |
| import { showNewMessage } from "@intercom/messenger-js-sdk"; | |
| type IntercomNewMessageProps = { | |
| message?: string; | |
| delayMs?: number; | |
| }; | |
| export default function IntercomNewMessage({ | |
| message = "", | |
| delayMs = 250, | |
| }: IntercomNewMessageProps) { | |
| useEffect(() => { | |
| const timeoutId = window.setTimeout(() => { | |
| showNewMessage(message); | |
| }, delayMs); | |
| return () => { | |
| window.clearTimeout(timeoutId); | |
| }; | |
| }, [message, delayMs]); | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment