setPageTitle

Sets the title of the current dashboard page in the browser tab.

The setPageTitle() function supports dashboard page extensions only. It does not support dashboard plugin extensions.

Call the setPageTitle() function whenever the page reloads, or to apply a new title when updating a page's content dynamically, without reloading.

Set the page title to null to reset the title to the default dashboard page title.

Signature

Copy
(pageTitle: string) => void

Parameters

NameTypeDescription
pageTitlestring or nullPage title to set.

Returns

void

Examples

To set up a dashboard client, refer to the setup guide.

Set a page title

Copy
setPageTitle("Product: Green apples");

Set page title to a product ID

This code is for a page that includes a product ID in the URL's query params.

Copy
client.dashboard.observeState((_, environmentState) => { // Use a regular expression to capture the productId value. const queryParams = environmentState.pageLocation.search; const productIdMatch = queryParams.match(/[?&]productId=([^&]+)/); let productId; if (productIdMatch) { productId = productIdMatch[1]; } // If a product ID was found, set the page title to the ID. if (productId) { client.dashboard.setPageTitle(`Product: ${productId}`); // If no product ID was found, reset the page title to default. } else { client.dashboard.setPageTitle(null); } });
Did this help?