0
0
NextJSframework~5 mins

Sub-path routing for locales in NextJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is sub-path routing for locales in Next.js?
Sub-path routing for locales means using a part of the URL path to show the language or region, like '/en' for English or '/fr' for French. It helps users see the site in their language by changing the URL prefix.
Click to reveal answer
beginner
How do you enable sub-path routing for locales in Next.js?
You enable it by setting the 'locales' and 'defaultLocale' options in the 'i18n' section of 'next.config.js'. Next.js then adds the locale as a path prefix automatically.
Click to reveal answer
beginner
What does the URL look like with sub-path routing for the French locale?
The URL will start with '/fr', for example, 'https://example.com/fr/about' to show the French version of the About page.
Click to reveal answer
intermediate
How does Next.js handle navigation between locales with sub-path routing?
Next.js updates the URL path prefix to the selected locale automatically when you use the 'next/link' component or the 'router.push' method with locale options.
Click to reveal answer
intermediate
Why is sub-path routing better than query parameters for locales?
Sub-path routing is clearer and better for SEO because the language is part of the URL path, making it easier for search engines and users to understand the page language.
Click to reveal answer
Which part of the URL represents the locale in sub-path routing?
AA cookie value
BA query parameter (e.g., '?lang=en')
CThe first segment after the domain (e.g., '/en')
DThe file extension
Where do you configure locales for sub-path routing in Next.js?
AIn 'next.config.js' under the 'i18n' key
BIn a '.env' file
CInside each page component
DIn the 'package.json' file
What happens if you visit a URL without a locale prefix when sub-path routing is enabled?
ANext.js redirects to the default locale with the prefix
BThe page shows an error
CThe page loads without any locale
DThe locale is guessed from the browser language but URL stays the same
How do you programmatically change the locale with sub-path routing in Next.js?
AChange the URL query string manually
BUse 'router.push' with the 'locale' option
CReload the page with a different cookie
DUse a custom server to rewrite URLs
Which benefit does sub-path routing provide over query parameters for locales?
AAutomatic translation of content
BFaster page loading
CSmaller bundle size
DBetter SEO and clearer URLs
Explain how sub-path routing for locales works in Next.js and how you set it up.
Think about how the URL changes and where you tell Next.js about your languages.
You got /4 concepts.
    Describe the advantages of using sub-path routing for locales compared to other methods like query parameters.
    Consider what users and search engines see in the URL.
    You got /4 concepts.