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

149
Views
NextJS Dynamic favicon and title

Greetins, I'm trying to build a webconstructor. Right now my application works like that:

  1. I check the url the user is on (for example localhost:3000)
  2. I get his project name on my webconstructor (localhost:3000 -> projectName: project1)
  3. I fetch the user's website data (for example favicon and title) (project1: {favicon: 'url', ...} Is it possible to render the favicon and title before the user enters the page so that it shows the right favicon and title in the browser. Right now I can only get it via useEffect in the main App component (but it's not good for seo). I have tried with getInitialProps but it doesn't seemd to do the job.

Thank you in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yeah it is possible to render dynamic favicon and title. Using the Head component from next/head. You can also create a GenericHead component that you can use whenever you want. Something like:

import Head from 'next/head'

const GenericHead: FC<{ title?: string; favicon?: string }> = (props) => {
  const { title, favicon } = props
  return (
    <Head>
      {title ? <title>{title}</title> : <title>Document</title>}
      <meta
        name='description'
        content='your description'
      />
      <link rel='icon' href={favicon ? favicon : '/favicon.ico'} />
    </Head>
  )
}

You can add more things to this GenericHead, like OpenGraph meta tags. And use it whenever you want

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!