Install target
One v1 widget script in the app shell
Install AnswerLattice
App Router and Pages Router guidance for installing the v1 widget once and updating route context.
One v1 widget script in the app shell
Path, title, feature, workflow, role, locale
Loaded, origin allowed, route allowed, context received
Install verification
Script, allowed origin, blocked route, safe context, and fallback checks are visible before product users rely on support.
Add the v1 widget script and safe context adapter.
Verify origin, route, context, and fallback readiness.
Go live only after the runtime checks pass.
'use client';
import Script from 'next/script';
import { usePathname } from 'next/navigation';
import { useCallback, useEffect } from 'react';
export function AnswerlatticeInstall() {
const pathname = usePathname() || '/';
const widgetKey = process.env.NEXT_PUBLIC_ANSWERLATTICE_WIDGET_KEY;
const updateContext = useCallback(() => {
if (!widgetKey) return;
window.AnswerlatticeWidget?.page({
path: pathname,
title: document.title,
feature: pathname.split('/').filter(Boolean)[0] || 'app',
role: 'member',
locale: navigator.language || 'en',
});
}, [pathname, widgetKey]);
useEffect(() => {
updateContext();
}, [updateContext]);
if (!widgetKey) return null;
return (
<Script
id="answerlattice-widget"
src="https://answerlattice.com/widget/v1/answerlattice-widget.js"
data-answerlattice-key={widgetKey}
strategy="afterInteractive"
onLoad={updateContext}
/>
);
}