Stopping the Calling SDK

Hi all,

I have a site that I also want to use as a calling SDK app. As you may know, a HubSpot app will only ‘work’ if an instance of the calling SDK’s useCti is running in the background of your app, otherwise HubSpot will show the app as ‘disconnected’.

For unrelated reasons I start a separate useCti instance at different stages of the app use (logging in, main app view, and some more), with the idea that only 1 instance should be active at the time.

However, it seems some of these instances persist, meaning that I get duplicate useCti broadcast messages for each of them when calls are going on. I can imagine that will create headache in the future, so how do I make sure an unwanted useCti instance is closed? It doesn’t have a Clear() or Close() method, I can only use useCti to create more instances or interact with them with the cti object.

Hey there!

You’re right having multiple useCti instances running can definitely cause issues like duplicate broadcasts. Since useCti doesn’t provide a built-in clear() or close() method, the best way to manage this is by ensuring each instance is properly unmounted when it’s no longer needed.

If you’re using React, make sure to only call useCti in components that are guaranteed to unmount when switching views, and avoid calling it in multiple places at once. You can also track active instances using a shared ref or global state to prevent duplicates.

Let me know if this helped you!

Dilion Smith