Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!