Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
React title changing based on domain

I have 2 domains in my React project that works like, "develop.something.com" and "develop.somethingnew.com". Currently both the domains taking the index.html file's title. But, now I want to set the separate individual titles for both the domains via the array methods or via the other methods when they are appeared on the UI. How should I go about implementing this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Based on window.location object (which has the host name details) you can set the title

function buildTitle(href) {
  const titles = {
    "develop.something.com": "Some title",
    "develop.somethingnew.com": "New Title",
  };
  const key = Object.keys(titles).find((t) => href.includes(t));
  return key ? titles[key] : "Default title";
}

function updateTtile(title) {
  window.document.title = title;
}

// In the component
updateTitle(buildTitle(window.location.href));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda