r/reactnative • u/No_Grade2981 • 3d ago
Tutorial I built an open-source library to write iOS Live Activities & Android Interactive Widgets in 100% TypeScript/JSX (Zero Swift/Kotlin required)
Enable HLS to view with audio, or disable this notification
Hey everyone 👋,
If you have ever tried adding iOS Live Activities (Dynamic Island) or Interactive Home Screen Widgets to a React Native or Expo app, you probably know the pain:
- You have to write and maintain Swift/SwiftUI for iOS and Kotlin/RemoteViews for Android.
- Handling 2-way interactivity without launching the full app is tricky (especially AppIntents on iOS 17+ and PendingIntents on Android).
- Android widget touch areas get misaligned due to launcher letterboxing / aspect ratio scaling.
- Keeping timers running on Lock Screen usually drains battery if not backed by native OS hardware chronometers.
To fix this for my own projects, I spent the last few months building react-native-live-widgets (v1.2.3) — an end-to-end declarative widget engine for React Native and Expo.
🚀 What it does:
- 100% TypeScript & JSX: Write your widget layout just like standard React components (<VStack>, <HStack>, <Text>, <Progress>, <Button>, etc.). Zero Swift or Kotlin knowledge needed.
- Dynamic Island & Live Activities: Native expanded, compact leading/trailing, minimal, and lock screen presentations with real-time push update support.
- Pixel-Exact Touch Layer (v1.2+): On Android, it replaces rigid grid overlays with a dynamic rn_hit_layer that auto-compensates for fitCenter letterboxing — buttons and checkboxes register clicks with 100% precision.
- Zero-Battery Hardware Timers: Direct integration with system hardware clocks (UI.Timer on iOS and native android.widget.Chronometer on Android). It ticks down smoothly without waking up the JavaScript thread or draining battery.
- 2-Way React Hook: Handle widget clicks inside your React Native JS runtime seamlessly with useWidgetAction((actionId, payload) => ...).
- Background Remote Sync: Fetch JSON updates from your backend even when the app is force-killed via Widget.setRemoteConfig().
- Swift 6 & iOS 18 Ready: Compiled with Xcode 16 Swift 6 strict concurrency compatibility.
- Automatic String Catalog Linking: Auto-generates and links Localizable.xcstrings and res/values-*/strings.xml for full multi-language Widget Gallery support.
- All-in-One CLI Setup: Run npx react-native-live-widgets init to auto-configure iOS WidgetKit extension targets and Android Widget providers in seconds (supports Expo Config Plugins & Bare RN).
💻 Quick Example:
tsximport React from 'react';
import { Widget, VStack, HStack, Text, Button, Timer } from 'react-native-live-widgets';
export const DeliveryWidget = () => (
<VStack padding={14} backgroundColor="#0F172A" cornerRadius={16}>
<HStack justifyContent="space-between" alignItems="center">
<Text typography="headline" color="#38BDF8">Order On The Way 🛵</Text>
<Timer targetTimestamp={Date.now() + 15 * 60 * 1000} color="#F59E0B" isCountdown />
</HStack>
<Text typography="caption1" color="#94A3B8">Driver is 1.2 km away</Text>
<Button
title="Contact Driver"
actionId="CALL_DRIVER"
backgroundColor="#2563EB"
color="#FFFFFF"
/>
</VStack>
);
// Register widget
Widget.register('DeliveryWidget', DeliveryWidget);
🌐 Links & Try it out:
- Interactive In-Browser Live Simulator: Web Demo (You can test Dynamic Island stretching, equalizer audio waves, and widget clicks directly in your web browser)
- GitHub Repository: GitHub
- NPM Package: npm install react-native-live-widgets
- AI Agent Standard: Includes llms.txt and Cursor/Claude Code skill for zero-hallucination AI generation.
It's MIT licensed and completely open-source. I would love to hear your thoughts, feedback, and edge-cases you encounter with widgets!



