Developing Widgets
Voltra provides APIs that make building and testing Home Screen widgets easier during development.
VoltraWidgetPreview component
VoltraWidgetPreview is a React Native component for testing and developing Voltra widget content. It renders Voltra JSX components at the exact dimensions of specific iOS widget families. This is useful for:
- Testing component layouts before deploying to widgets
- Previewing how your widget will look across different sizes
- Developing and iterating on widget content within your React Native app
VoltraWidgetPreview is a regular React Native component. Use it in your React Native screens, not inside Voltra components.
Props:
family: Widget family size to preview (systemSmall, systemMedium, systemLarge, etc.)style: Additional React Native styles to applyid: Unique identifier for the view (used for event filtering)onInteraction: Callback for user interactions with buttons/toggles
updateWidget API
The updateWidget function allows you to update home screen widget content with new data.
Widget updates are throttled to around an update per minute. iOS limits how frequently widgets can be refreshed to preserve battery life and system performance.
Parameters:
widgetId: The widget identifier (as defined in your config plugin)variants: An object mapping widget families to specific contentoptions.deepLinkUrl: URL to open when the widget is tapped
scheduleWidget API
For widgets that need to change throughout the day, scheduleWidget lets you batch multiple updates in advance. iOS will automatically display each entry at its scheduled time—even when your app isn't running.
This is perfect for weather forecasts, calendar events, news rotation, or any content that changes on a predictable schedule.
Parameters:
widgetId: The widget identifier (as defined in your config plugin)entries: Array of timeline entries, each containing:date: When this content should be displayedvariants: Widget content for different size familiesdeepLinkUrl(optional): URL to open when tapping this specific entry
With deep links per entry:
iOS controls when widgets actually update based on battery level, widget visibility, and system load. While you can schedule entries at any interval, iOS typically enforces a minimum of ~15 minutes between updates. Entries scheduled more frequently may be delayed or coalesced.
Best practices:
- Schedule entries at realistic intervals (15+ minutes apart)
- Don't schedule hundreds of entries—iOS has a daily refresh budget
- Use
updateWidgetfor immediate one-time updates - Use
scheduleWidgetfor predictable, recurring content changes
Widget configuration via Expo plugin
Widgets are configured through the Voltra Expo config plugin. Add the widget configuration to your app.json or app.config.js:
Widget Configuration Properties:
id: Unique identifier for the widget (alphanumeric with underscores only)displayName: Name shown in the widget gallerydescription: Description shown in the widget gallerysupportedFamilies: Array of supported widget sizes (defaults to systemSmall, systemMedium, systemLarge)
Fallback logic for variants
When a widget size doesn't have specific content defined, Voltra automatically falls back to other available variants in this order:
systemMedium(preferred fallback for home screen widgets)systemSmallsystemLargesystemExtraLargeaccessoryRectangularaccessoryCircularaccessoryInline
This ensures your widget always displays content even when a specific size variant isn't provided. For example, if you only define systemSmall and systemLarge, a systemMedium widget will use the systemSmall content.
Additional widget APIs
reloadWidgets
Force widget timelines to refresh their content after updating shared resources like preloaded images:
clearWidget / clearAllWidgets
Remove stored widget data, causing widgets to show their placeholder state:
