Single-page apps
The messenger follows route changes in React, Vue, Svelte and any other single-page app. It listens to the History API, so most apps need no extra code, and update calls are never dropped.
Automatic route tracking
When the URL changes through pushState, replaceState or the back button, the SDK sends the new page context to Gripz. Page targeting, the AI agent and your teammates' details panel all see the page the visitor is on. The messenger stays open and keeps its place in the thread.
Gripz('boot', {
workspaceId: 'tw_8f2k',
routeTracking: 'auto' // the default. Use 'manual' for hash routers
});Set the route yourself
Hash routers and screens that change without a new URL can send the page context themselves. Turn on manual tracking, then call update after each navigation.
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
export function GripzRouteSync() {
const location = useLocation();
useEffect(() => {
Gripz('update', {
page: { path: location.pathname, title: document.title }
});
}, [location]);
return null;
}Update calls are never dropped
| Merging | Updates sent within the same second become one request. The newest value of each field wins. |
|---|---|
| Fair use | Only a runaway loop reaches the ceiling of 1,000 updates per session per hour. The SDK then writes a warning with a link to this page in the browser console, and the messenger keeps working. |
| Offline | If Gripz cannot be reached, commands wait in a queue for up to 5 minutes and are sent when the connection returns. Errors never throw into your page. |
Sign-in and sign-out
A single-page app rarely reloads, so tell the messenger when the person changes. On a shared computer this keeps one person's conversations away from the next.
| When | Call | What happens |
|---|---|---|
| After sign-in | identify | Pass the signed token. Earlier anonymous conversations in this browser are merged into the contact. |
| After sign-out | shutdown | Clears the identity, the messenger's cookies, local storage and loaded conversations, then boots again as an anonymous visitor. |
| Missed sign-out | None needed | If a user ID that was identified before is missing on the next boot, the SDK resets on its own. |