Interactive previews iPhone

Custom Session Async URL Image

A modifier that adds a URL session for asynchronous images contained in the view to use when fetching image data.

Custom Session Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview

Platform Compatibility

iOS 27.0+ iPadOS 27.0+ macOS 27.0+ watchOS 27.0+ tvOS 27.0+ visionOS 27.0+

Tags

SwiftUI Code

Docs
let imageURL = URL(string: "https://exploreswiftui.com/images/cats.jpg")!
let imageSession: URLSession = {
    let configuration = URLSessionConfiguration.default
    configuration.httpAdditionalHeaders = [
        "X-Custom-Header": "CustomValue"
    ]

    return URLSession(configuration: configuration)
}()

var body: some View {
    AsyncImage(request: URLRequest(url: imageURL)) { image in
        image
    } placeholder: {
        ProgressView()
    }
    .asyncImageURLSession(imageSession)
}

Found an issue or have a suggestion?

Created: June 9, 2026Updated: June 9, 2026

More AsyncImage Components

View all
Custom Placeholder Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Custom Placeholder Async URL Image

Loads and displays a modifiable image from the specified URL load request using a custom placeholder until the image loads.

Custom Phases Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Custom Phases Async URL Image

Loads and displays a modifiable image from the specified URL load request in phases.

Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Async URL Image

Loads and displays an image from the specified URL load request.

Explore Other Components

Browse all
AccessoryCircularGaugeStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

AccessoryCircularGaugeStyle

A gauge style that displays an open ring with a marker that appears at a point along the ring to indicate the gauge’s current value

Delete Disabled - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
modifier

Delete Disabled

Adds a condition for whether the view’s view hierarchy is deletable.

Gauge - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Gauge

Creates a gauge showing a value within a range and describes the gauge’s purpose and current value

LinearCapacityGaugeStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

LinearCapacityGaugeStyle

A gauge style that displays a bar that fills from leading to trailing edges as the gauge’s current value increases

Item Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Item Alert

Presents an alert using the given data to produce the alert’s content and a text view as a title.

PalettePickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

PalettePickerStyle

A picker style that presents the options as a row of compact elements. When used outside of menus, this style is rendered as a segmented picker. If that is the intended usage, consider segmented instead.

Section Index Label and Visibility - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Section Index Label and Visibility

Sets the label that is used in a section index to point to this section, typically only a single character long. Changes the visibility of the list section index.

Content Unavailable Search Text - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
type

Content Unavailable Search Text

A pre-built placeholder for empty search results with search text