Before starting, ensure you have CocoaPods 1.16.2+, Xcode 16+, and Expo SDK 53+ installed. See the installation guide for details.
Create your first widget
Generate a widget target
Run the This command will:
create-target CLI in your Expo project root:- Create a
/targets/widgetdirectory with Swift template files - Install the
@bacons/apple-targetspackage - Add the Config Plugin to your
app.json - Generate an
expo-target.config.jsfile
You can also use
npx create-target without arguments to see a list of all available target types.Configure your Apple Team ID (optional)
If you know your Apple Team ID, add it to your You can find your Team ID in Xcode under Signing & Capabilities. If you don’t have it now, you can set it later.
app.json:app.json
Generate the Xcode project
Run prebuild to generate your iOS project with the widget target:This creates the Xcode project and links your widget files to the
expo:targets/widget virtual folder.Open in Xcode
Open your project in Xcode:Navigate to the expo:targets folder in the project navigator. You’ll see your widget files there. Any changes you make here will be saved to
/targets/widget in your project root.Customize your widget
Edit the widget configuration at
/targets/widget/expo-target.config.js:targets/widget/expo-target.config.js
The
$accent color is used for button tints when editing the widget. The $widgetBackground sets the widget’s background color.Share data between your app and widget
Widgets can display data from your React Native app using App Groups andNSUserDefaults.
Configure App Groups
First, define an App Group in yourapp.json:
app.json
targets/widget/expo-target.config.js
Set data from React Native
In your Expo app, use theExtensionStorage API:
App.tsx
Read data in Swift
In your widget’s Swift code, access the shared data:targets/widget/widgets.swift
npx expo prebuild --clean after changing the config, then rebuild in Xcode.
Next steps
Target configuration
Learn about colors, images, frameworks, and deployment targets
App Clips
Build instant app experiences with App Clips
Code signing
Understand code signing for extensions
Advanced topics
Explore CocoaPods, shared files, and more
Troubleshooting
Widget doesn’t show on home screen
- Make sure you’re using iOS 18 or later
- Long-press the app icon and select widget display options
- Try clearing SwiftUI preview cache:
xcrun simctl --set previews delete all
Build errors with SwiftUI previews
React Native ships uncompiled, which can cause Swift compiler issues. Try:Changes not appearing after prebuild
If you modifyexpo-target.config.js or app.json, you must run:
expo:targets folder in Xcode will be overwritten by prebuild.