How to prompt users to configure widgets in iOS 18

Issue #996

When creating widgets for iOS, especially those that need user input to be useful, one common challenge is guiding the user to configure them. Before iOS 18, a user would add a widget, but then would have to know to long-press it and select “Edit Widget” to set it up. This wasn’t always obvious.

With iOS 18, Apple has introduced a simple solution to improve this user experience: the promptsForUserConfiguration modifier.

This new modifier, when applied to your widget’s configuration, tells the system to automatically prompt the user to configure the widget right after they add it to their Home Screen

You can add promptsForUserConfiguration() to your widget configuration. It works with configurations that require user setup, like those using App Intents.

Since promptsForUserConfiguration() is only available on iOS 18 and later, we can add a handy extension to make the compiler happy

extension WidgetConfiguration {
    func safePromptsForUserConfiguration() -> some WidgetConfiguration {
        if #available(iOS 18.0, *) {
            return self.promptsForUserConfiguration()
        } else {
            return self
        }
    }
}

Then you can use safePromptsForUserConfiguration() in your widget code

struct MyWidget: Widget {
    var body: some WidgetConfiguration {
        AppIntentConfiguration(kind: "com.example.mywidget", intent: ConfigurationIntent.self, provider: Provider()) { entry in
            MyWidgetEntryView(entry: entry)
        }
        .configurationDisplayName("My Awesome Widget")
        .description("A widget that needs your input.")
        .safePromptsForUserConfiguration()
    }
}
Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation