Single-page apps
Add the widget to a React, Next.js, Vue or other app that changes pages without reloading.
Last updated Tuesday, November 24th, 2026
View as MarkdownOn this page
An app that swaps pages in place keeps one document for the whole visit, so the widget needs adding once, not on every route. It stays on screen, and keeps its conversation open, as your visitor moves around.
Paste it into the page shell
Put the snippet in the HTML every route shares: index.html in a Vite or Create React App project, or the root layout in a framework that renders on the server. Only the first init call counts, so a layout that renders again never draws a second widget.
In a Vite project, that's index.html, below the element your app mounts in:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Brightline</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
window.$notert=window.$notert||[];window.notert=window.notert||new Proxy({},{get:(_,p)=>typeof p=="string"&&p!="then"&&/^[a-z]/i.test(p)?(...a)=>window.$notert.push([p,...a]):void 0});
window.notert.init("YOUR_WORKSPACE_ID",{widget:true,theme:"page"});
</script>
<script type="module" async src="https://app.notert.io/embed/v1.js"></script>
</body>
</html>The small script runs before your app's module, since a module waits for the page to be read, so window.notert exists by the time your components call it.
A framework that swaps the whole <body> as it changes pages, such as Turbo, Astro's view transitions, Livewire's wire:navigate or htmx's hx-boost, needs nothing more: the widget puts itself back in the new page, with its conversation and anything your visitor typed.
In Next.js, add both scripts to the root layout with next/script. The small one goes beforeInteractive, so window.notert exists before any of your components run:
// app/layout.tsx
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script id="notert" strategy="beforeInteractive">
{`window.$notert=window.$notert||[];window.notert=window.notert||new Proxy({},{get:(_,p)=>typeof p=="string"&&p!="then"&&/^[a-z]/i.test(p)?(...a)=>window.$notert.push([p,...a]):void 0});
window.notert.init("YOUR_WORKSPACE_ID",{widget:true,theme:"page"});`}
</Script>
<Script src="https://app.notert.io/embed/v1.js" type="module" strategy="afterInteractive" />
</body>
</html>
);
}In TanStack Start, add both to the root route's head(), which renders them on every page with your document's nonce. React may move the module ahead of the small script, which works: either one that runs first leaves the other what it needs.
// src/routes/__root.tsx
export const Route = createRootRoute({
head: () => ({
scripts: [
{
children: `window.$notert=window.$notert||[];window.notert=window.notert||new Proxy({},{get:(_,p)=>typeof p=="string"&&p!="then"&&/^[a-z]/i.test(p)?(...a)=>window.$notert.push([p,...a]):void 0});
window.notert.init("YOUR_WORKSPACE_ID",{widget:true,theme:"page"});`,
},
{ src: "https://app.notert.io/embed/v1.js", type: "module", async: true },
],
}),
});In Remix, Nuxt, SvelteKit or Astro, put both scripts in the root layout's document, rendered on the server, never from a component that only draws in the browser.
Tell it who signed in
When a visitor signs in or out without the page reloading, call identify with the change, from your sign-in and sign-out code rather than a script rendered with the page, which doesn't run again. Until it's called, the widget keeps the person who signed out, so on a shared computer the next one would open their conversations. The widget starts over for the new person, with nothing it read for the one before:
useEffect(() => {
// A token your server signed for this user, or null once they've signed out.
window.notert.identify(user ? user.notertToken : null);
}, [user]);An app people leave open for longer than a day passes a function that fetches a fresh token instead, which the widget calls whenever it needs one. See keep the token fresh.
How your server makes notertToken is in sign a token on your server. Your secret stays on the server, so the browser can't make the token: sign it for each request on the server and send it with the data the page already gets for the signed-in user, such as a route loader's answer, a server component's props or a value in the HTML. A signer that only runs on the server answers nothing in the browser, and the widget then keeps whoever it had: only null signs someone out.
Start it only for some people
The snippet starts the widget for everyone your page is served to. To keep it from some of them, such as users under a certain age, a tenant that turned it off, or a visitor who declined consent, keep both scripts in the layout and take window.notert.init(...) out of the inline one, then call it from your own code once you know this person may have it:
useEffect(() => {
if (user && user.mayUseSupportChat) {
window.notert.init("YOUR_WORKSPACE_ID", { widget: true, theme: "page" });
}
}, [user]);Until init is called, the widget's script loads nothing more, draws nothing and stores nothing. Where someone who mustn't have it can sign in without a reload, take it off the page on that sign-in with shutdown, and start it again with identify and init for the next person who may:
useEffect(() => {
if (user && user.mayUseSupportChat) {
window.notert.identify(user.notertToken);
window.notert.init("YOUR_WORKSPACE_ID", { widget: true, theme: "page" });
} else {
window.notert.shutdown();
}
}, [user]);Open it from a button in your app
In an app, put the widget behind your own Help button rather than the round one in the corner: pass launcher: false to init, which the install guide does when you pick Your own button, and give your button data-notert-toggle. In React, the button can show what the round button does too: a green dot while someone on your team is available, and how many replies wait unread in its place:
import { useEffect, useState } from "react";
export function HelpButton() {
const [state, setState] = useState({ unseen: 0, online: false });
useEffect(() => {
const listener = ({ unseen, online }: { unseen: number; online: boolean }) =>
setState({ unseen, online });
window.notert.on("change", listener);
return () => window.notert.off("change", listener);
}, []);
return (
<button type="button" data-notert-toggle>
Help
{state.unseen > 0 ? (
<span className="badge">{state.unseen}</span>
) : (
state.online && (
<span className="online-dot">
<span className="sr-only">Online</span>
</span>
)
)}
</button>
);
}In Vue, the same button with the npm package's types:
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from "vue";
import { notert, type NotertState } from "@notert/widget";
const state = ref<NotertState>({ open: false, unseen: 0, online: false });
const listener = (next: NotertState) => {
state.value = next;
};
onMounted(() => notert.on("change", listener));
onUnmounted(() => notert.off("change", listener));
</script>
<template>
<button type="button" data-notert-toggle :aria-expanded="state.open">
Help
<span v-if="state.unseen > 0" class="badge">{{ state.unseen }}</span>
<span v-else-if="state.online" class="online-dot"><span class="sr-only">Online</span></span>
</button>
</template>See your own button for the rest.
Suggest articles for the screen they're on
Your team picks the help articles the widget's first screen suggests for each page, by its address. Where your app shows different screens at one address, such as a settings dialog or a tab kept in state, name the articles yourself with suggest as the screen changes, and pass [] to hand the choice back:
useEffect(() => {
// Help articles by their ids, the last part of each one's address in Notert.
window.notert.suggest(tab === "billing" ? ["0b7e0c8e-6f1a-4c55-9d4c-0e2a0d6c1f00"] : []);
}, [tab]);Follow your app's dark mode
With theme: "page", the widget follows your app's own light and dark switch by itself, where the switch sets a dark class or a theme attribute on <html> or <body>, as most do. Where yours doesn't, tell the widget each time it flips:
window.notert.appearance({ theme: dark ? "dark" : "light" });The widget follows at once. See light, dark or match your site.
Let Back close it on a phone
On a phone the widget fills the screen, so your visitor may reach for the Back gesture to close it, which would leave your page instead. Pass closeOnBack: true to init and Back closes the widget:
window.notert.init("YOUR_WORKSPACE_ID", { widget: true, theme: "page", closeOnBack: true });It's off unless you turn it on, because it adds an entry to your page's history while the widget is open full screen: one at the same address, keeping your router's state, which the widget takes away again when it closes another way. A router that reacts to every Back, rather than to a change of address, may draw the page again as it does. Try it on a phone before you ship it.
While the widget fills the screen, your page keeps still behind it whether or not you pass closeOnBack, and scrolls as it did once the widget closes.
Follow your app's language
Pass language: "page" to init and the widget speaks the language your app's <html lang> names, among the languages your workspace offers, and follows your app as its own language menu changes it without a reload. An app that keeps its language elsewhere names it each time it changes:
window.notert.appearance({ language: "de" });See choose its language.
TypeScript
window.notert isn't typed for you. Install @notert/widget and import notert from it instead: it has every call typed, works whether the snippet or the package loaded the widget, and does nothing on the server. In React, its useNotert() hook gives your Help button the widget's count and green dot without the listener above.
import { notert } from "@notert/widget";
notert.open({ screen: "help" });