Performance
Voltra provides automatic optimizations to help you create efficient Live Activities, but following these best practices will ensure optimal performance and stay within ActivityKit's payload size limits.
Element deduplication
Reuse JSX elements by creating them once, storing them in variables, and reusing them across your JSX tree. Voltra automatically detects duplicate element references and stores them only once in the payload, using lightweight references ({ $r: index }) for subsequent occurrences.
Payload result:
Benefits:
- Eliminates redundant element serialization
- Can significantly reduce payload size for complex UIs
- Works across different Live Activity variants
- Automatic - no additional code required
Image optimization
Images can significantly impact payload size. For comprehensive guidance on handling images in Live Activities, see the Images documentation, which covers:
- Base64 encoding for small static images
- Build-time asset copying for medium-sized images
- Runtime preloading for dynamic images
Choose the appropriate approach based on your image size, when it's known, and whether it changes dynamically.
Reuse style objects
Reuse style objects and avoid inline styles when possible:
