Skip to main content
Answered

Issue with Svelte-kit and Intercom messenger

  • 18 July 2024
  • 1 reply
  • 41 views

Hello Intercom Team,

I’m facing an issue with loading the Intercom messenger in my SvelteKit web app. Sometimes, the messenger in both the local environment and the deployed environment gives an error and it does not showing up, also in firefox it does not work at all:

 

Uncaught TypeError: Cannot read properties of undefined (reading 'parentNode')
at s (index.YkDx8vIC.js:2:4217)


layout.svelte: (run only in client side)
 

<script lang="ts">
import '../app.css';
import '../fonts.css';
import { Toaster } from '$lib/components/ui/sonner';
import { onMount } from 'svelte';
import { browser } from '$app/environment';

onMount(async () => {
if (browser) {
const { Intercom } = await import('@intercom/messenger-js-sdk');
Intercom({
app_id: 'XXXX'
});
}
});
</script>

Additionally, I tested it in a normal server-client setup, and it also gives the same error.

How can I fix the issue?

1 reply

Userlevel 3
Badge +4

Hi @Roshan Ghojoghi ! Ebenezer here from Engineering Support👋.

I see you were able get an answer concerning this from my colleague.

I’ll post the solution in here.

As Svelte is a framework which is commonly implemented as an SPA.

We have an article that goes through the installation method for this type of site, I'm going to link it below to review ⏬

https://www.intercom.com/help/en/articles/170-integrate-intercom-in-a-single-page-app?location=conversation

Hope this helps!

Reply