Native React Hook & Wrapper Component for Single-Page Applications
Integrate Rajlav AI seamlessly into modern React applications. Utilize clean TypeScript interfaces, declarative props, and custom trigger hooks for single-page apps (SPAs).
import { useEffect } from 'react';
export function SmartConnectWidget({ businessId }: { businessId: string }) {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://staging.rajlav.co.in/widget/smart-connect.js';
script.setAttribute('data-business-id', businessId);
script.setAttribute('data-position', 'bottom-right');
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, [businessId]);
return null;
}Engineered for Performance & Scalability
TypeScript First
Complete TypeScript definitions for widget events, state callbacks, and configuration props.
Declarative State
Control widget visibility, open/closed drawer state, and user context via React props.
Zero Re-Render Overhead
Carefully isolated from your React virtual DOM tree to avoid unnecessary component re-renders.
Custom Open Hooks
Trigger the chat window programmatically from any custom button using `useSmartConnect()`.
How to Connect React in 4 Steps
Add Script or Component
Include the lightweight script loader component in your React root layout or App component.
Pass Business ID Prop
Configure your verified Rajlav AI Business ID and position preferences.
Inject User Context (Optional)
Pass logged-in user details (email, user ID) to associate chats with customer accounts.
Build & Deploy
Works seamlessly with Vite, Create React App, Webpack, and modern bundlers.
Compatible Rajlav AI Modules
Frequently Asked Questions
Does this work with client-side routers like React Router?
Yes! The widget persists across client-side page transitions without re-initializing or losing conversation state.
Can I pass custom user data from my React state?
Yes! You can attach custom metadata (e.g. current subscription tier, customer ID) via window-level configuration before widget boot.
Is the component compatible with React 18 and 19?
Yes! Fully compatible with React 18, 19, and concurrent rendering.
