UNPKG

inertia-title

Version:

Simple auto update title plugin for Inertia.js client adapters

23 lines (21 loc) 477 B
// src/title.ts import { router } from "@inertiajs/core"; function setTitle(value) { if (typeof document === "undefined") return; setTimeout(() => document.title = value, 1); } function inertiaTitle() { if (typeof document === "undefined") return; router.on("navigate", (event) => { const title = event.detail.page.props.title; setTitle(title); }); } function useInertiaTitle() { inertiaTitle(); } export { setTitle, inertiaTitle, useInertiaTitle };