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

313
Views
nextjs router locale undefined

I have done a lot of research and tried many things, but unfortunately, I haven't found a solution, so I had to ask again.

I am working locally on a project and now I want to add Internationalized Routing from nextjs to my project so that I can offer it in 2 languages... I read the documentation of nextjs and watched youtube tutorials and tried but it always comes back in locale:undefined and unfortunately I don't know why?

below you can see my codes... Can you maybe tell me what I am not doing right? or what I am doing wrong?

index.tsx

export default function Home({ posts }: Props) {
  const router = useRouter()
  const t = router.locale === 'de' ? de : tr

  console.log(router)

  return (
      <Header />
      <main className="flex w-full flex-1 flex-col items-center justify-center px-20 text-center">
        <h1 className="text-6xl font-bold">
          {t.title}
          <a className="text-blue-600" href="https://nextjs.org">
            Next.js!
          </a>
        </h1>

        <div>
          <Link href="/" locale="de">
            <a>DE </a>
          </Link>
          <Link href="/tr" locale="tr">
            <a>TR</a>
          </Link>
        </div>
)

enter image description here

next.config.js

/** @type {import('next').NextConfig} */
module.exports = {
  reactStrictMode: true,
  i18n: {
    locales: ['de', 'tr'],
    defaultLocale: 'de',
  },
}

locales/de.js

export const de = {
  title: 'Welcome to ',
}


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

0

Try this


export default function Home({ posts }: Props) {
  const router = useRouter()
  let t = "";

 useEffect(()=>{

   t = router.locale === 'de' ? de : tr
   
 },[]);

  return (
      </>
    Your Other Code ...
        </>
)

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!