Embedding the chat widget (React)
Embedding the chat widget (React)
Embedding the chat widget (React)
For React applications, use the React embed code from the Ship tab of your chat Surface for tighter integration with your app’s component lifecycle.
The generated code uses @runtypelabs/persona to initialize the chat widget within a React component, including cleanup on unmount.
Install the Persona package:
Paste the generated code from the Ship tab into your React component. The code handles:
useRefdestroy() on component unmountThe Ship tab generates a complete working component. Customize it further as needed for your application.
Chat widgets use Client Tokens (with the ct_live_ or ct_test_ prefix) instead of API keys. They are safe to expose in client-side code. Create and manage them in the Auth tab of your chat Surface.