In my Next.js project, I change the page title dynamically in reaction to an event:
if (unread_count === 0) {
document.title = "Flow Chat";
} else {
document.title = `Flow Chat - ${unread_count} unread messages`;
}
The default title of the page is set in the layout.tsx
:
export const metadata: Metadata = {
title: "Flow Chat",
description: [...],
};
Is it possible to reset the page title to the one set in metadata
instead of hardcoding the text a second time?