curtis
05/22/2024, 1:25 PMVapi Support
05/22/2024, 1:25 PMVapi Support
05/22/2024, 1:25 PMTypeError: __vite_ssr_import_5__.default is not a constructor suggests that the Vapi module is not being correctly recognized as a constructor, possibly due to how modules are handled in SSR.
To resolve this issue, ensure that the Vapi SDK import is conducted in a client-side context only. SvelteKit differentiates between server and client code execution, and you might need to dynamically import the Vapi SDK within onMount to ensure it only executes client-side:
javascript
import { onMount } from 'svelte';
let vapi;
onMount(() => {
import('@vapi-ai/web').then((module) => {
vapi = new module.default('your-public-key');
});
});
This snippet ensures that the Vapi SDK is only initialized on the client side, avoiding errors related to server-side rendering. If you continue to experience issues, you may need to review the configuration of your setup to ensure compatibility with SSR and SvelteKit [(1)]() .Vapi Support
05/22/2024, 1:27 PMSahil
05/22/2024, 3:09 PM