The pealHQ widget displays your workspace’s published announcements directly in your website or application. A button opens the changelog in a centred popup or a side panel, without leaving the page.
You can share this guide with your technical team or a coding agent. The URLs use a fictitious acme workspace: replace them with the URL generated in your settings. No secret or API key is needed to install the widget on a public portal.
Prepare the widget
- Open Settings → Changelog widget in the pealHQ admin.
- Choose Centred popup or Side panel. The choice is saved immediately for the workspace.
- Choose the colour of the dot that shows the number of unseen updates.
- Click Test the widget to preview the result.
- Choose Floating button or Embedded button, then copy the code provided.
- Install this code on your site and publish an announcement in the changelog to check the result.
The widget displays the workspace’s published announcements, from newest to oldest, with their title, summary, content and any cover image. Drafts are excluded. When there is no published announcement, it displays a placeholder message.
To embed a YouTube video in an announcement, paste its link on its own line, separated from the text by a blank line, or use the YouTube video button in the editor. The video plays directly in the widget, in full screen if needed, and stops when the widget is closed. A link placed inside a sentence or with a label remains a plain link.
Always copy the script URL from the settings. It can take one of these forms depending on your environment:
https://acme.pealhq.com/widget/changelog.js
https://preview.example/w/acme/widget/changelog.js
The choice between popup and side panel is made in pealHQ, not in a script attribute. It takes effect the next time the script loads; a page that is already open keeps its configuration. Caching of 60 seconds may delay the change.
Install a floating button
Paste this code once, before the </body> tag of your page or in your site’s global template:
<script async src="https://acme.pealhq.com/widget/changelog.js"></script>
The script creates a What’s new button in the bottom right-hand corner. A click opens or closes the widget. The panel can also be closed with its close icon or by clicking the backdrop outside it.
The script loads asynchronously. On a public portal, the changelog content is loaded in an iframe the first time it opens. On a private portal, an authenticated background load also initialises the counter as soon as the widget loads.
Install an embedded button
Place the button where you want it in your page, for example in the navigation bar:
<button type="button" data-peal-changelog-button></button>
<script async data-trigger="false" src="https://acme.pealhq.com/widget/changelog.js"></script>
pealHQ fills in and styles this button: icon, What’s new label and unseen updates badge. The data-trigger="false" attribute on the script removes the floating button; it does not disable the widget.
The content and style of the embedded button are replaced by the widget. To keep your own appearance or label, use a custom button instead.
Use your own button
Add data-peal-changelog to your existing button:
<button type="button" class="mon-bouton" data-peal-changelog>
Les dernières améliorations
</button>
<script async data-trigger="false" src="https://acme.pealhq.com/widget/changelog.js"></script>
This button keeps its content and appearance. A click opens the widget. Use a real button with an accessible label; on a link, the widget does not cancel the default navigation.
You can place several triggers on the page with a single script. Buttons added to the DOM later are detected automatically. The data-peal-unread-count attribute is updated on the triggers with the current number of unseen updates; on a custom button, no visual badge is added automatically.
To display a badge in your own button, add a data-peal-unread-badge element:
<button type="button" class="mon-bouton" data-peal-changelog>
Nouveautés
<span class="mon-badge" data-peal-unread-badge aria-hidden="true" style="display:none"></span>
</button>
The widget writes the number of unseen updates into it, displays it as inline-flex and hides it at zero. It also applies the dot colour chosen in the settings (background and readable text) and centres the number. The size, position, shape and line height remain those of your CSS; a line-height: 1 stops it from looking vertically offset.
Control the widget with JavaScript
Once the script has loaded, the window.PealChangelog object exposes these methods:
| Method | Effect |
|---|---|
open() | Opens the widget. On a private portal, announcements are marked as seen after the authenticated load succeeds. |
close() | Closes the widget. |
toggle() | Switches between open and closed. |
destroy() | Removes the widget, the floating button and its listeners; deletes the global object. Embedded buttons generated by pealHQ are emptied. |
Example to place in the click handler of a button in your application:
function afficherLesNouveautes() {
if (window.PealChangelog) {
window.PealChangelog.open();
}
}
As the script is asynchronous, the object may not exist yet at first render. A call made before it loads is not queued. To open the widget automatically, wait for the script to load and for the DOM to be ready.
Two events are dispatched on window when the widget opens and closes:
function onChangelogOpen() {
console.log('Le changelog est ouvert');
}
function onChangelogClose() {
console.log('Le changelog se ferme');
}
window.addEventListener('peal:changelog:open', onChangelogOpen);
window.addEventListener('peal:changelog:close', onChangelogClose);
// Au démontage de votre composant, retirez vos propres écouteurs :
// window.removeEventListener('peal:changelog:open', onChangelogOpen);
// window.removeEventListener('peal:changelog:close', onChangelogClose);
These events carry no user identity or announcement details. The close event is dispatched at the start of the animation. Properties prefixed with __ are for internal use and are not configuration options.
Integrate with React or an application with client-side navigation
Load the script once in the HTML document or in your framework’s script-loading mechanism. Avoid injecting it on every page change.
For a React button, use a custom trigger and let pealHQ detect when it appears:
export function BoutonNouveautes() {
return (
<button type="button" data-peal-changelog>
Nouveautés
</button>
);
}
Load the script separately with data-trigger="false". This button does not need an additional onClick handler. The custom trigger stops pealHQ from replacing the content of an element managed by React.
Only one widget instance is available per window. Loading a second script while window.PealChangelog exists does not change the workspace. If your application needs to switch workspace without reloading the page, call destroy(), remove the old script tag, then load the one for the new workspace. destroy() does not reload anything and does not clear the history of seen announcements. If you manage this cycle in a React effect, also plan its cleanup and any asynchronous loads still in progress on unmount.
Understand the updates counter
The badge on buttons generated by pealHQ shows the number of announcements that this browser has not yet marked as seen. It is hidden at zero and shows 99+ above 99.
- On the first visit, all published announcements retrieved by the widget are considered unseen. The counter works on public and private portals.
- On a public portal, opening the widget immediately marks the known announcements as seen. On a private portal, they are marked as seen only after the popup’s authenticated load succeeds. Loading the counter in the background and an access refusal never mark them as seen.
- The state is kept in the
localStorageof the site that embeds the widget, under the keypeal:changelog:{slug}:seen. - This state is specific to the browser and to the site’s origin, not to a pealHQ account. It is not synchronised between devices, sites or users sharing a browser.
- If storage is blocked, the widget remains usable, but the state does not persist across reloads. Clearing the site’s data also resets the counter on the storage side: the announcements then reappear as unseen.
In an announcement’s editor, the Open this announcement automatically option tells the widget to open on the next load in every browser where this announcement is still unseen. The widget only opens once the announcement is published. It also works with data-trigger="false" and on a private portal once the authenticated background load succeeds. It opens the full changelog, then follows the same rules as any other opening for marking announcements as seen. Several announcements configured this way trigger only one opening.
This option relies on the same local state as the counter: it applies once per browser and per origin, not per account. If several people share the same browser, the first opening counts for all of them. If storage is blocked or cleared, the automatic opening may happen again on a later load.
The list used by the counter is retrieved when the widget loads. For a private portal, an invisible iframe goes through the same authenticated route as the popup, passes the published identifiers to the widget, then is removed. No private announcement identifier is included in the public script. On every private opening, the list is refreshed after authentication. There are no real-time updates: reload the page to refresh the badge after a new publication. Closing and reopening a public widget does not reload its iframe.
Appearance and portal access
The button uses the workspace’s accent colour. The colour of the counter dot is set separately in Settings → Changelog widget; its text colour adapts automatically to stay readable. The widget content uses the accent and background colours when the plan allows customisation. Hiding the “Powered by pealHQ” mention also depends on the workspace setting and its plan. Links to the terms remain present.
The changelog content is isolated in an iframe: your site’s CSS styles do not change its content. To customise your trigger, use data-peal-changelog. There is no script option to change the text of the generated button or its position, or to select only certain announcements.
Embed a private portal in an authenticated application
A private portal stays private. The /widget/changelog.js script is accessible without signing in and contains no private announcements or private announcement identifiers. The /widget/changelog page checks access before loading the announcements. Without valid proof, it responds with HTTP 403 and a message in the popup, with no redirect to a sign-in page.
Your application’s session is not passed to pealHQ automatically. For customers already signed in to your product, enable SSO mode in the customer sign-in settings and use a route in your backend to sign their identity. This flow works without a second sign-in and without third-party cookies: the token only authorises the response containing the announcements, without opening a pealHQ session or creating an account.
<button type="button" data-peal-changelog-button></button>
<script async data-trigger="false" data-auth-url="/peal/changelog-widget" src="https://acme.pealhq.com/widget/changelog.js"></script>
data-auth-url points to a GET route that you create in your application, on the same domain as the page that embeds the button. It is not a pealHQ route. Adapt this path to your backend. Without data-trigger="false", the same flow works with the floating button.
- When the widget loads, an invisible iframe calls this route to initialise the unseen updates counter. The popup also calls this route every time it opens. The background load does not mark any announcement as seen.
- Your backend checks the session and the authorisation to access this organisation, then generates a fresh SSO JWT from the signed-in account.
- It responds with HTTP 302 to
https://acme.pealhq.com/widget/changelog?token=JWT_ENCODE, withCache-Control: no-storeandReferrer-Policy: no-referrer. Copy the widget URL shown in your settings; in path mode, it includes/w/{slug}. - pealHQ validates the token’s signature, audience, expiry and single use, then loads the announcements in the iframe. The widget retrieves their identifiers through a
postMessageexchange that checks the pealHQ origin and the sending window, to update the counter. Use/widget/changelog, not/sso/callback, which opens a session for the standard portal.
Server-side PHP example, to call from your authenticated route. The PEAL_SSO_AUDIENCE and PEAL_SSO_SECRET variables come from the SSO settings; PEAL_WIDGET_URL is the full URL of /widget/changelog shown on the integration page.
<?php
function pealWidgetUrl(array $authenticatedUser): string
{
$widgetUrl = getenv('PEAL_WIDGET_URL');
$audience = getenv('PEAL_SSO_AUDIENCE');
$secret = getenv('PEAL_SSO_SECRET');
if (! $widgetUrl || ! $audience || ! $secret || strlen($secret) < 32) {
throw new RuntimeException('Configuration du widget pealHQ manquante.');
}
$encode = static fn (string $value): string =>
rtrim(strtr(base64_encode($value), '+/', '-_'), '=');
$now = time();
$header = $encode(json_encode(['alg' => 'HS256', 'typ' => 'JWT'], JSON_THROW_ON_ERROR));
$claims = $encode(json_encode([
'aud' => $audience,
'sub' => (string) $authenticatedUser['id'],
'email' => $authenticatedUser['email'],
'name' => $authenticatedUser['name'],
'iat' => $now,
'exp' => $now + 60,
'jti' => bin2hex(random_bytes(16)),
], JSON_THROW_ON_ERROR));
$signature = $encode(hash_hmac('sha256', "$header.$claims", $secret, true));
$separator = str_contains($widgetUrl, '?') ? '&' : '?';
return $widgetUrl.$separator.http_build_query([
'token' => "$header.$claims.$signature",
], '', '&', PHP_QUERY_RFC3986);
}
In the Laravel route of your application, after checking the session and permissions:
return redirect()->away(pealWidgetUrl([
'id' => $request->user()->id,
'email' => $request->user()->email,
'name' => $request->user()->name,
]))->withHeaders([
'Cache-Control' => 'no-store',
'Referrer-Policy' => 'no-referrer',
]);
The secret stays exclusively on your backend. Never take the identity from arbitrary browser parameters. If your framework caches environment variables, inject them through its configuration. The SSO guide details the required fields and also provides a Node.js example: use the same JWT format, with the /widget/changelog URL as the destination.
The token is single-use and expires after 120 seconds at most; the example uses 60 seconds. Generate it on every call to the route, including for the background counter, without caching the redirect or placing a fixed token in the snippet. On every reopening, the widget reloads your backend route with a new token. On closing, the private content of the iframe is removed. When users sign out of your application, call window.PealChangelog?.destroy() to immediately remove a popup that is still open.
An authorised pealHQ session remains usable without a token, notably for the admin preview. It then depends on the browser’s cookies: this preview does not replace a test of the SSO flow from your application.
Troubleshoot an integration problem
| Symptom | Check |
|---|---|
| No button visible | Check that the script loads in the Network tab. If data-trigger="false" is present, add an embedded or custom button. |
PealChangelog is missing | Wait for the script to finish loading. Check the URL, content blockers and the browser console. |
| HTML response instead of JavaScript, redirect or 403 | The script must respond with 200 as JavaScript, even on a private portal. Check the URL and that the fix has been deployed. |
| “Sign-in required” in the private popup | Check data-auth-url, your application’s session, SSO mode and the generation of a fresh JWT for the right audience. An expired, already used or invalid token is refused. |
| 404 response | Copy the full URL again from the settings of the right workspace, including the /w/{slug} prefix where there is one. |
| The button works, but the panel is empty or blocked | Check the request to /widget/changelog, the access rules and the embedding site’s security policy. |
| An announcement is missing | Check that it is published and in the right workspace, then reload the page. Drafts are not displayed. |
| The mode or the badge looks out of date | Reload the page. On a private portal, also check that the data-auth-url route succeeds as soon as the page loads; the counter requires this authenticated access. |
| The custom button also navigates the page | Use <button type="button"> rather than a link. |
| The widget shows another workspace | Keep a single instance per window; destroy the old one before loading another. |
If your site uses a Content Security Policy (CSP), its policy must allow the script to load from the portal’s origin (script-src) and the iframe from that same origin (frame-src). For the private flow, frame-src must also allow 'self', since the iframe starts with your application’s route. The script also applies styles directly to the elements it creates: a policy that forbids these styles can prevent rendering. Have your technical team adapt the directives to its security policy, using the errors in the console.
Check before publishing
- Test from your embedding site, in a private window if your portal is public: the preview in the admin may benefit from your signed-in session.
- Open and close the widget on desktop and mobile, then test the button with the keyboard.
- Check that a published announcement appears and that a draft stays hidden.
- Check that the badge disappears after opening and stays hidden on reload in the same browser when storage is allowed.
- Publish a new announcement and reload the page to check the counter, including on a private portal before the popup is opened. Check that a refused access does not mark the announcements as seen.
- In a React application, change page and check the new triggers, as well as the absence of a duplicate floating button.
- For an announcement set to open automatically, first test in a browser that has never seen it, then reload the page and check that the widget does not open a second time.
Find the other guides in the documentation and their shareable versions in the Markdown index.