Language and Currency Synchronization
VeChainKit supports bidirectional synchronization of language and currency preferences between the kit and host applications. This allows changes made in either the kit's settings or the host app to be reflected in both places.

Overview
The bidirectional sync feature enables:
Kit → Host: When users change language or currency in VeChainKit settings, the host app can be notified and update accordingly
Host → Kit: When the host app changes language or currency, VeChainKit automatically reflects these changes
Features
Language Synchronization
Language preferences are synchronized between:
VeChainKit's language settings (accessible via Account Modal → Settings → General → Language)
Host application's i18n instance
Browser localStorage (
i18nextLng)
Currency Synchronization
Currency preferences are synchronized between:
VeChainKit's currency settings (accessible via Account Modal → Settings → General → Currency)
Host application's state
Browser localStorage (
vechain_kit_currency)
Usage
Basic Setup
The bidirectional sync is enabled automatically when you use VeChainKitProvider. You can optionally provide callbacks to be notified of changes:
Reading Current Values
Using Convenience Hooks
The easiest way to access current language and currency values:
Using useVeChainKitConfig Hook
You can also access current values through the config hook:
Changing Values from Host App
You can change language or currency from your host app, and VeChainKit will automatically sync:
Listening to Changes
Use the optional callback props to react to changes made in VeChainKit:
In your i18n.ts file be sure to check localstorage for setting the language, to avoid issues during refresh.
API Reference
VeChainKitProvider Props
language?: string
Initial language code (e.g., 'en', 'fr', 'de'). Defaults to 'en'.
defaultCurrency?: CURRENCY
Initial currency code ('usd', 'eur', or 'gbp'). Defaults to 'usd'.
onLanguageChange?: (language: string) => void
Optional callback fired when language is changed in VeChainKit settings.
onCurrencyChange?: (currency: CURRENCY) => void
Optional callback fired when currency is changed in VeChainKit settings.
Hooks
useCurrentLanguage()
Returns the current language and a function to change it.
Returns:
currentLanguage: string- Current language codesetLanguage: (language: string) => void- Function to change language
useCurrentCurrency()
Returns the current currency and a function to change it.
Returns:
currentCurrency: CURRENCY- Current currency codesetCurrency: (currency: CURRENCY) => void- Function to change currency
useVeChainKitConfig()
Returns the full VeChainKit configuration including current language and currency.
Returns:
currentLanguage: string- Current runtime language valuecurrentCurrency: CURRENCY- Current runtime currency valuesetLanguage: (language: string) => void- Function to change languagesetCurrency: (currency: CURRENCY) => void- Function to change currency... (other config properties)
Storage
Language and currency preferences are persisted in browser localStorage:
Language:
i18nextLng(managed by react-i18next)Currency:
vechain_kit_currency
Changes persist across page reloads and browser sessions.
Notes
Use
currentLanguageandcurrentCurrencyfromuseVeChainKitConfig()to get the current runtime values.Changes made in VeChainKit settings automatically update localStorage and trigger callbacks.
Changes made via
setLanguage()orsetCurrency()from the host app automatically sync to VeChainKit.The sync works bidirectionally - changes in either direction are reflected in both places.
Last updated
Was this helpful?