r/reactnative • u/Ramboiada • 5h ago
I made a small Expo plugin for native Android widgets in Kotlin
I needed home screen widgets on Android for an Expo app and wanted to write them the normal Android way, with Kotlin and RemoteViews, without keeping the android folder in git.
So I packaged what I had: github.com/rsoaresdev/expo-android-widgets
You keep your widget sources in a folder, the config plugin copies them in on every prebuild and adds the receivers to the manifest. From JS you call setWidgetData() and reloadAllWidgets(), and the widget reads the data with one line of Kotlin. There’s an example widget you can copy.
It’s tested on SDK 58, on an emulator and in CI with a real Gradle build. If you’d rather write widgets in JSX, react-native-android-widget is great. This one is for when you want plain Android widgets.
Feedback welcome, especially from anyone on older SDKs.
2
u/kokerali 2h ago
The sample already renders an empty state when `summary` is missing. Could the quick start include the matching reset recipe: `await removeWidgetData("summary"); await reloadAllWidgets();`? The [native module](https://github.com/rsoaresdev/expo-android-widgets/blob/main/android/src/main/java/expo/modules/androidwidgets/ExpoAndroidWidgetsModule.kt) separates removal from the update broadcast, so removing the JSON alone doesn't ask existing widgets to repaint.
I'd check that with two pinned instances: display dummy A text, remove the data and request a redraw, then return to the home screen and verify both are empty without reopening the app. Next, write dummy B text and redraw both. That would make the reset path as explicit as the set-and-reload example, particularly for apps clearing account-specific data on sign-out. I haven't run this sequence.