A sample Expo / React Native app demonstrating how to build Android home screen widgets using react-native-android-widget.
- 🟢 Android home screen widget built with React Native components
- 👁️ In-app widget preview screen
- 🔔 Widget lifecycle handling (add, update, resize, delete, click)
- ⚡ React Native New Architecture enabled
Sin.titulo.mov
expo-android-widget-sample/
├── app/
│ ├── _layout.tsx # Root layout (bare Stack navigator)
│ └── index.tsx # Single screen — renders the widget preview
├── widgets/
│ ├── MyCustomWidget.tsx # Widget UI component + preview screen
│ └── widget-task-handler.tsx # Widget lifecycle event handler
├── scripts/ # Utility scripts
├── assets/ # Icons, images, widget preview images
├── index.ts # Entry point — registers widget task handler
├── app.json # Expo configuration (widget plugin included)
└── eas.json # EAS Build configuration
- Node.js 18+
- Expo CLI
- Android Studio (for emulator / device builds)
- An EAS account if using cloud builds
Note: Widgets only work on Android. The app runs on iOS and Web as well, but the widget functionality is Android-only.
npm installWidgets require a development build — they do not work in Expo Go.
Local build (requires Android Studio):
npx expo run:androidCloud build via EAS:
eas build --profile development --platform androidnpx expo startThen press a to open on an Android emulator or connected device.
- Long-press an empty area of your Android home screen.
- Tap Widgets.
- Find your widget and drag it onto the home screen.
All widget lifecycle events are handled in widgets/widget-task-handler.tsx. The handler receives a widgetAction and dispatches accordingly.
Click actions are string identifiers set via clickAction on any FlexWidget element. The handler currently recognises:
update_widget
To add a new click action, set clickAction="your_action" on a FlexWidget in MyCustomWidget.tsx and add a matching branch inside the WIDGET_CLICK case in widget-task-handler.tsx.
| Command | Description |
|---|---|
npm run android |
Run on Android |
npm run ios |
Run on iOS |
npm run web |
Run on web |
npm run lint |
Run ESLint |
Defined in eas.json:
| Profile | Distribution | Build type |
|---|---|---|
development |
Internal | APK |
preview |
Internal | APK |
production |
Store | APK (auto-increment version) |
| Package | Purpose |
|---|---|
expo ~54 |
Expo SDK |
react-native 0.81 |
React Native runtime |
react-native-android-widget |
Android widget support |
expo-router |
File-based navigation |
expo-dev-client |
Custom development builds |