Advanced Usage
SSR Configuration
The plugin fully supports server-side rendering (SSR) scenarios.
Server-side Language Detection
In SSR scenarios, the plugin will detect language from HTTP requests:
- URL Path: Extract language prefix from path
- Cookie: Read language settings from cookies
- Request Headers: Read from
Accept-Languagerequest header
Configuration Example:
SSR Resource Loading
In SSR scenarios, the plugin will automatically use the file system backend to load resources:
Resource file structure:
Multi-Entry Configuration
If the project has multiple entries, you can configure language detection and backend options separately for each entry.
Configure Language Detection by Entry
Configure Backend by Entry
Custom i18next Instance
If you need to use a custom i18next instance, you can provide it in runtime configuration.
Create Custom Instance
Pass Custom Instance
Language Switching
Programmatic Switching
Use the changeLanguage method of the useModernI18n Hook:
URL Synchronization
When localePathRedirect is enabled, switching languages will automatically update the URL:
If localePathRedirect is not enabled, language switching will only update the i18next instance and cache, without changing the URL.