Challenge - 5 Problems
Domain Routing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2: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' }
]
}
}Attempts:
2 left
💡 Hint
Check how the domains array maps domains to locales.
✗ Incorrect
Next.js uses the domain to determine the locale if domain routing is configured. Since example.fr is mapped to 'fr', the locale will be French.
📝 Syntax
intermediate2: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' }
]
}
}Attempts:
2 left
💡 Hint
Look for missing brackets or punctuation.
✗ Incorrect
Option C is missing the closing bracket for the domains array, causing a syntax error.
❓ state_output
advanced2:00remaining
What locale is used when domain and path locale conflict?
Consider this Next.js i18n config:
If a user visits https://example.fr/en/about, what locale will Next.js use?
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?
Attempts:
2 left
💡 Hint
Think about how Next.js prioritizes path locale vs domain locale.
✗ Incorrect
When both domain and path locale are present, Next.js prioritizes the path locale prefix over the domain locale.
🔧 Debug
advanced2:00remaining
Why does locale domain routing fail to switch locale?
A developer configures Next.js i18n domains as:
But when visiting https://example.fr, the locale remains 'en'. What is the most likely cause?
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?
Attempts:
2 left
💡 Hint
Check deployment and domain setup for Next.js apps.
✗ Incorrect
If the app is not deployed or configured to recognize example.fr as a domain, Next.js cannot apply domain locale routing.
🧠 Conceptual
expert2: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?
Attempts:
2 left
💡 Hint
Think about user experience and SEO benefits of domain routing.
✗ Incorrect
Domain routing lets you serve different languages on different domains, which can improve SEO and make URLs cleaner and more intuitive for users.