Minor Changes
-
#4313
28fe67047a0
Thanks @abdellah711! - feat: dynamic window title for NextJSpages
directoryThis feature enables users to generate document titles for each page in NextJS
pages
directory. To activate it, users need to include theDocumentTitleHandler
component within the<Refine>
component. By default, theDocumentTitleHandler
will generate titles using thegenerateDefaultDocumentTitle
exported from@refinedev/core
.The
DocumentTitleHandler
component accepts an optional prop calledhandler
, which is a callback function. This function is triggered whenever thepathname
changes and receives an object with the following parameters:{ resource, // 'posts' action, // 'create' params, // {id: 1} pathname, // '/posts/create' autoGeneratedTitle; // 'Create new Post | refine' }
The
handler
callback should return the new title based on the provided parameters.To update the title in a child component, the user can use the
useDocumentTitle
hook. It accepts either a string representing the new title or an object with the propertyi18nKey
if the app supports multiple languages.useDocumentTitle({ i18nKey: "documentTitle.default" });
Note that this hook doesn't support SSR, and it will generate the titles in the client-side only.