Widget Pre-rendering (Android)
Widget pre-rendering allows you to provide a meaningful initial state for your Android widgets before they are updated by the app for the first time.
Configuration
Add initialStatePath to your widget configuration in the @use-voltra/android-client plugin in app.json:
For multiple locales, set initialStatePath to a map of locale tag → file path (same pattern as iOS); the first-run payload matches the device locale when possible.
Implementation
Create a file at the specified initialStatePath that exports a default Voltra component (or a React element). For Android, this should use VoltraAndroid primitives.
initialStatePath files are not part of your React Native app bundle. They run in Node.js during prebuild. Import VoltraAndroid from @use-voltra/android, not @use-voltra/android-client — the client package pulls in native modules that are unavailable in the prebuild sandbox.
Build Process
During the build process (npx expo prebuild), Voltra executes these initial state files in a Node.js environment to generate the static layouts that will be displayed when the widget is first added to the home screen.
Limitations
- Environment: The code runs in Node.js during build time, not on the device.
- Imports: Use
@use-voltra/androidfor JSX and types ininitialStatePathfiles. Do not import from@use-voltra/android-clientor other React Native client APIs. - Static Content: The initial state should represent a "loading" or "offline" state, as it won't have access to dynamic runtime data until the app runs.
