How To Stop a Web Call using Nextjs (React)
# support
r
After Testing the web call using normal html and js from the documentation things went pretty well, but the problem that i'm having is how to stop a web call. the docs says that i need to put vapi.stop(), i did it but i can't stop a web call, i have to refresh. Another Issue: when i trigger the web call after putting the public key and assistant id, it goes through, but when put the values dynamically the web call doesn't go throught so what is the correct way to handle dynamic value for this
v
To stop a web call in your Next.js (React) app, ensure your
vapi
instance is accessible and call
vapi.stop()
in your event handler. For example:
Copy code
js
const handleStopCall = () => {
  vapi.stop();
};
Attach this to your "Stop Call" button. If the call doesn't end, double-check that the
vapi
instance is not being re-created on every render and is properly initialized at the component level. Reference: [Vapi Web SDK Docs – .stop()](https://docs.vapi.ai/sdk/web#stop) Source: - [Vapi Web SDK Docs – .stop()](https://docs.vapi.ai/sdk/web#stop)
k
Ensure vapi.stop() is called after the call-start event and on the correct instance while for dynamic assistant ID and public key, make sure values are valid, set before vapi.start(), and properly awaited if fetched asynchronously..
checking if this is resolved/solved for you?
v
Message marked as helpful by @RamonJ! 🎉