Context
Get more details about the components of the Widget.
If you want to know how to install the widget in your application follow the next steps.
NxWhatsApp Hook context
Main hook context required to integrate un your root app.
src/NxWhatsApp.tsx
// Import NxWhatsApp context hook
import { NxWhatsApp } from "@nuveraxgroup/widget";
// Tag context
<NxWhatsApp>
<App/>
</NxWhatsApp>
// Props from NxWhatsApp
export interface NxWhatsAppProps {
children: ReactNode;
authDomain?: string;
}
| Property | Required | Description |
|---|---|---|
authDomain | ❌ | Use to define the authentication domain. Default value https://wa.nuverax.com/. |
children | ✅ | React children component. |
WhatsAppWidget component
src/WhatsAppWidget.tsx
// Import WhatsAppWidget component
import {WhatsAppWidget} from "@nuveraxgroup/widget";
// Component tag
<WhatsAppWidget
onAuthResult={
(isAuth: boolean, token: string) => {
// After a success authentication
}
}/>
// Props from WhatsAppWidget
export interface WhatsAppWidgetProps {
appId?: string;
onAuthResult: (isAuth: boolean, token: string) => void;
}
| Property | Required | Description |
|---|---|---|
appId | ❌ | Appication id to start authentication flow (we will load information from this app). |
onAuthResult | ✅ | Result event of the authentication. isAuth: true is the authentication was succesful. token: JSON Web Token of the current session. |
useNxWhatsAppContext Hook
Handle session state of the user.
src/NxWhatsAppContext.ts
// Import useNxWhatsAppContext hook
import {useNxWhatsAppContext} from "@nuveraxgroup/widget";
// Hook call
const waContext = useNxWhatsAppContext()
// Props from useNxWhatsAppContext
export interface NxWhatsAppContextProps {
getToken: (appId?: string) => Promise<string | null>;
authenticated: boolean;
isAUth: () => Promise<boolean>;
logout: (appId?: string) => Promise<void>;
}
| Property | Description |
|---|---|
getToken | Retrieves the current JSON Web Token of the user session (we already handle refresh tokens, so you always get a valid token). - appId: Your application id. |
authenticated | true if the user has an active session. Usefull with useEffect hook. |
isAUth | Retrieves the current session status. true is the user has an active session. |
logout | Logout all the current sessions. - appId: Your application id, we will redirect to your specific app endpoint after a success logout. |