Widget Pre-rendering
Widget pre-rendering allows you to provide meaningful initial state for widgets before they are synced when the app runs for the first time.
Configuration
Section titled “Configuration”Add initialStatePath to your widget configuration in app.json:
{ "expo": { "plugins": [ [ "@use-voltra/ios-client", { "widgets": [ { "id": "weather", "displayName": "Weather Widget", "description": "Shows current weather conditions", "supportedFamilies": ["systemSmall", "systemMedium", "systemLarge"], "initialStatePath": "./widgets/weather-initial.tsx" } ] } ] ] }}Localized initial states
Section titled “Localized initial states”Use a locale map so the config plugin pre-renders one bundle per language; iOS and Android pick the best match at runtime from the device locale (fallback order: preferred languages → language-only → en → first locale):
"initialStatePath": { "en": "./widgets/weather-initial.tsx", "pl": "./widgets/weather-initial-pl.tsx"}Implementation
Section titled “Implementation”Create a file at each configured path that exports a WidgetVariants object (or use the same file path for multiple locales if copy is identical):
import { Voltra, type WidgetVariants } from '@use-voltra/ios'
const initialState: WidgetVariants = { systemSmall: <Voltra.Text>Content</Voltra.Text>, systemMedium: <Voltra.Text>Content</Voltra.Text>, systemLarge: <Voltra.Text>Content</Voltra.Text>,}
export default initialStateLimitations
Section titled “Limitations”- Node.js Environment: Code runs in Node.js, not in React Native or iOS
- Babel Support: TypeScript is supported via Babel transpilation
- No Bundling: Import resolution works for local files but there is no bundler involved
- Voltra Imports: Use
@use-voltra/iosfor JSX and types ininitialStatePathfiles. Do not import from@use-voltra/ios-clientor other React Native client APIs.