Files
ServerKit/frontend/src/hooks/usePageTitle.js
T
Juan Denis 5dec8ba81e Add site settings and dynamic page titles
Introduces a Site Settings tab in the Settings page for admins to toggle user registration. Adds dynamic page title updates based on route, updates the favicon and meta tags, and conditionally shows the registration link on the login page based on the registration setting. Also adds a reusable usePageTitle hook.
2026-01-22 20:23:33 -05:00

19 lines
460 B
JavaScript

import { useEffect } from 'react';
/**
* Hook to set the page title
* @param {string} title - The page title (will be appended with " | ServerKit")
*/
export function usePageTitle(title) {
useEffect(() => {
const previousTitle = document.title;
document.title = title ? `${title} | ServerKit` : 'ServerKit';
return () => {
document.title = previousTitle;
};
}, [title]);
}
export default usePageTitle;