0
0
NextJSframework~10 mins

Domain routing for locales in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the default locale in Next.js domain routing.

NextJS
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: '[1]',
    domains: []
  }
}
Drag options to blanks, or click blank then click option'
Aen
Bes
Cfr
Dde
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a locale not listed in the locales array.
Leaving the defaultLocale empty.
2fill in blank
medium

Complete the code to add a domain for the French locale in Next.js domain routing.

NextJS
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    domains: [
      {
        domain: '[1]',
        defaultLocale: 'fr'
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Aexample.es
Bexample.com
Cexample.de
Dexample.fr
Attempts:
3 left
💡 Hint
Common Mistakes
Using the English domain for the French locale.
Using a domain with the wrong country code.
3fill in blank
hard

Fix the error in the domain routing config by completing the missing property.

NextJS
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    domains: [
      {
        domain: 'example.com',
        [1]: 'en'
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Alang
Blocale
CdefaultLocale
Dlanguage
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'locale' or 'lang'.
Omitting the property entirely.
4fill in blank
hard

Fill both blanks to configure domain routing for English and French locales.

NextJS
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: '[1]',
    domains: [
      {
        domain: '[2]',
        defaultLocale: 'fr'
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Aen
Bexample.fr
Cexample.com
Dfr
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the domain names for the locales.
Using locale codes instead of domain names.
5fill in blank
hard

Fill all three blanks to complete the Next.js domain routing config with English and French locales and domains.

NextJS
module.exports = {
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: '[1]',
    domains: [
      {
        domain: '[2]',
        defaultLocale: '[3]'
      }
    ]
  }
}
Drag options to blanks, or click blank then click option'
Aen
Bexample.fr
Cfr
Dexample.com
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up domain names and locale codes.
Setting defaultLocale to a domain name instead of a locale code.