Why This Matters
In SPAs, route changes happen without full page reloads. That means components like the Copilot might not automatically reappear when a user navigates to a new page—unless they’re re-injected manually. The good news? Adopt handles this for you. With a simpleaddRouter()
setup, the SDK will detect route changes and keep everything running smoothly.
How to Set Up SPA Routing
Use theaddRouter()
method to pass your app’s navigation handler to Adopt. This allows the Copilot to stay in sync with your routing system.
React Example (using React Router)
Script/CDN:
NPM Package:
Vue Example
Angular Example
Custom Routing
If you’re using a custom framework or vanilla JS:Automatic Re-injection
Adopt automatically re-injects the Copilot components when a route change is detected. As long as the widget container (<div id="adopt-widget-container"></div>
) persists across views, no additional setup is required.
Good Practices
- Place the Copilot container outside of route-specific layouts (e.g. in a global wrapper)
- Always call
boot()
after login—even in SPAs - Use
shutdown()
on logout to clean up