# Swiftui Webkit

Embeds and controls web content in SwiftUI with WebKit for SwiftUI, including WebView...

- Repository: https://github.com/dpearson2699/swift-ios-skills (1266 stars)
- Category: Design
- License: see repository
- Last updated: 2026-07-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add dpearson2699/swift-ios-skills --skill swiftui-webkit -g -a claude-code -y`
Codex: `npx skills add dpearson2699/swift-ios-skills --skill swiftui-webkit -g -a codex -y`
Cursor: `npx skills add dpearson2699/swift-ios-skills --skill swiftui-webkit -g -a cursor -y`
Gemini CLI: `npx skills add dpearson2699/swift-ios-skills --skill swiftui-webkit -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add dpearson2699/swift-ios-skills`

## Description

Embeds and controls web content in SwiftUI with WebKit for SwiftUI, including WebView, WebPage, navigation policies, JavaScript execution, observable page state, link interception, local HTML or data loading, and custom URL schemes. Use when building iOS 26+ article/detail views, help centers, in-app documentation, or other embedded web experiences backed by HTML, CSS, and JavaScript.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# SwiftUI WebKit

Embed and manage web content in SwiftUI using the native WebKit-for-SwiftUI APIs introduced for iOS 26, iPadOS 26, macOS 26, and visionOS 26. Use this skill when the app needs an integrated web surface, app-owned HTML content, JavaScript-backed page interaction, or custom navigation policy control.

## Contents

- [Choose the Right Web Container](#choose-the-right-web-container)
- [Displaying Web Content](#displaying-web-content)
- [Loading and Observing with WebPage](#loading-and-observing-with-webpage)
- [Navigation Policies](#navigation-policies)
- [JavaScript Integration](#javascript-integration)
- [Local Content and Custom URL Schemes](#local-content-and-custom-url-schemes)
- [WebView Customization](#webview-customization)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)

## Choose the Right Web Container

Use the narrowest tool that matches the job.

| Need | Default choice |
|---|---|
| Embedded app-owned web content in SwiftUI | `WebView` + `WebPage` |
| iOS/iPadOS modal browsing with Safari behavior | `SFSafariViewController` |
| macOS or visionOS browse-out behavior | `openURL` / default browser |
| OAuth or third-party sign-in | `ASWebAuthenticationSession` |
| Back-deploy below iOS 26 or use missing legacy-only WebKit features | `WKWebView` fallback |

Prefer `WebView` and `WebPage` for modern SwiftUI apps targeting iOS 26+ when the new API surface covers the feature. Apple’s WWDC25 guidance frames existing UIKit/AppKit WebKit wrappers in SwiftUI apps as good candidates to try migrating, not as a blanket mandate to delete every fallback.

Do not use embedded web views for OAuth. That stays an `ASWebAuthenticationSession` flow.

## Displaying Web Content

Use the simple `WebView(url:)` form when the app only needs to render a URL and SwiftUI state drives navigation.

```swift
import SwiftUI
import WebKit

struct ArticleView: View {
    let url: URL

The rest: https://github.com/dpearson2699/swift-ios-skills/blob/HEAD/skills/swiftui-webkit/SKILL.md
