Set page title with Vue Router
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
# Dynamically Setting Page Titles with Vue Router: A Practical Guide
As developers building Single Page Applications (SPAs) with Vue and Vue Router, one of the most common requirements is ensuring that the browser tab title accurately reflects the current view. When you define meta titles within your route configuration (using `meta` properties), the next logical step is to dynamically display this title in your main content, such as an `` tag.
You've encountered a classic hurdle: attempting to use `$emit` within navigation guards to push data to a globally visible element often doesn't work as expected because routing state changes are handled internally by Vue Router, requiring specific hooks for global updates.
This guide will walk you through the correct, idiomatic ways to dynamically set your page title based on the current route, moving beyond the failed `$emit` attempt.
## Why `$emit` Fails in `beforeEach`
When you use `router.beforeEach`, its primary job is to intercept navigation *before* it happens (e.g., for authentication checks or redirecting). While you can emit events, these events are scoped to the component that emitted them and don't automatically propagate to a globally visible element like an `