logologo
Getting started
Development
Components
Getting started
Development
Components
logologo

Getting started

Introduction
Quick start
Prior art

Development

Managing Live Activities locally
Developing Live Activities
Developing Widgets
Widget pre-rendering
Images
Image preloading
Performance
Styling
Interactions
Events
Server-side updates

Components

Overview
Layout & containers
Visual elements & typography
Data visualization & status
Interactive controls

API Reference

Plugin Configuration
Configuration
Abstract Logo

Need React or React Native expertise you can count on?

Let's talkLet's talk
Edit this page on GitHub
Previous PageDeveloping Widgets
Next PageImages
Need help with React or React Native projects?
We support teams building scalable apps with React and React Native.
Let's talkLet's talk

#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

Add initialStatePath to your widget configuration in app.json:

{
  "expo": {
    "plugins": [
      [
        "voltra",
        {
          "widgets": [
            {
              "id": "weather",
              "displayName": "Weather Widget",
              "description": "Shows current weather conditions",
              "supportedFamilies": ["systemSmall", "systemMedium", "systemLarge"],
              "initialStatePath": "./widgets/weather-initial.tsx"
            }
          ]
        }
      ]
    ]
  }
}

#Implementation

Create a file at the specified initialStatePath that exports a WidgetVariants object:

import { Voltra, type WidgetVariants } from 'voltra'

const initialState: WidgetVariants = {
  systemSmall: <Voltra.Text>Content</Voltra.Text>,
  systemMedium: <Voltra.Text>Content</Voltra.Text>,
  systemLarge: <Voltra.Text>Content</Voltra.Text>,
}

export default initialState

#Build Process

During build time, Voltra transpiles your widget files with Babel and executes them in a Node.js environment to generate initial states that are bundled into the iOS app.

#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: Do not use voltra/client or voltra/server imports; use voltra instead