0
0
NextJSframework~20 mins

Domain routing for locales in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Domain Routing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does Next.js handle locale domain routing?
Given this Next.js configuration for i18n domain routing, what will be the locale when a user visits https://example.fr/about?

module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    domains: [
      { domain: 'example.com', defaultLocale: 'en' },
      { domain: 'example.fr', defaultLocale: 'fr' }
    ]
  }
}
AThe locale will be 'fr' because the domain example.fr is mapped to French.
BThe locale will be 'en' because the defaultLocale is always 'en' regardless of domain.
CThe locale will be 'en' because the path '/about' overrides domain locale settings.
DThe locale will be undefined because domain routing requires a special header.
Attempts:
2 left
💡 Hint
Check how the domains array maps domains to locales.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this Next.js domain routing config
Which option contains a syntax error in the Next.js i18n domain routing configuration?

module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    domains: [
      { domain: 'example.com', defaultLocale: 'en' },
      { domain: 'example.fr', defaultLocale: 'fr' }
    ]
  }
}
Adomains: [ { domain: 'example.com', defaultLocale: 'en' }, { domain: 'example.fr', defaultLocale: 'fr' } ]
Bdomains: [ { domain: 'example.com', defaultLocale: 'en' }, { domain: 'example.fr', defaultLocale: 'fr' } ],
Cdomains: [ { domain: 'example.com', defaultLocale: 'en' }, { domain: 'example.fr', defaultLocale: 'fr' }
Ddomains: [ { domain: 'example.com', defaultLocale: 'en' }, { domain: 'example.fr', defaultLocale: 'fr' } ];
Attempts:
2 left
💡 Hint
Look for missing brackets or punctuation.
state_output
advanced
2:00remaining
What locale is used when domain and path locale conflict?
Consider this Next.js i18n config:

module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    domains: [
      { domain: 'example.com', defaultLocale: 'en' },
      { domain: 'example.fr', defaultLocale: 'fr' }
    ]
  }
}

If a user visits https://example.fr/en/about, what locale will Next.js use?
ALocale 'fr' because domain locale has higher priority than path prefix.
BLocale 'en' because the path prefix '/en' overrides the domain locale.
CLocale 'en' because defaultLocale always overrides domain locale.
DLocale 'fr' because Next.js ignores path prefixes when domain routing is used.
Attempts:
2 left
💡 Hint
Think about how Next.js prioritizes path locale vs domain locale.
🔧 Debug
advanced
2:00remaining
Why does locale domain routing fail to switch locale?
A developer configures Next.js i18n domains as:

domains: [
  { domain: 'example.com', defaultLocale: 'en' },
  { domain: 'example.fr', defaultLocale: 'fr' }
]

But when visiting https://example.fr, the locale remains 'en'. What is the most likely cause?
AThe Next.js app is not deployed with the correct domain environment variables.
BThe user is visiting the site over HTTP, but domain routing requires HTTPS.
CThe browser cache is forcing the 'en' locale despite domain routing.
DThe i18n config is missing the 'localeDetection: false' setting.
Attempts:
2 left
💡 Hint
Check deployment and domain setup for Next.js apps.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of domain routing for locales in Next.js?
Why would a developer choose to use domain routing for locales instead of path-based locale prefixes in Next.js?
AIt forces users to always use the defaultLocale regardless of their browser settings.
BIt automatically translates content without needing manual locale files or translations.
CIt reduces server load by caching all locales on a single domain.
DIt allows serving different locales on separate domains, improving SEO and user experience by matching user expectations.
Attempts:
2 left
💡 Hint
Think about user experience and SEO benefits of domain routing.