swiftui-webkit

Embed and manage web content in SwiftUI using WebKit-for-SwiftUI APIs.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swiftui-webkit-dfly7
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swiftui-webkit
Source: https://github.com/DFly7/iOS-FastAPI-Supabase-AI/tree/main/.agents/skills/swiftui-webkit
Command: npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swiftui-webkit-dfly7

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Many SwiftUI apps need an embedded web surface that the app can observe, control, and integrate with native UI; this Skill explains how to correctly embed web content, run JavaScript, intercept navigation, and host bundled or offline HTML while avoiding common pitfalls and unsafe patterns.

Core Features & Use Cases

  • Modern SwiftUI WebKit guidance: prefer WebView and WebPage for iOS 26+ and observe page state such as title, url, estimated progress, and navigation events.
  • Navigation policy control: implement WebPage.NavigationDeciding to keep owned domains in-app and hand off external links safely.
  • JavaScript integration: callJavaScript with typed argument passing and defensive casting of results for page-driven interactions.
  • Local content and custom schemes: register URLSchemeHandler to serve bundled HTML/CSS/JS and handle cancellation semantics.
  • Migration and fallbacks: decision guide for when to use SFSafariViewController, ASWebAuthenticationSession, or WKWebView as intentional fallbacks.
  • Review checklist and common mistakes to validate safe, focused embedded web experiences.

Quick Start

Create a WebPage in your SwiftUI view, load the desired URL or local resource, observe title and loading progress, and implement a NavigationDeciding to route external links out of the embedded surface.

Frequently Asked Questions about swiftui-webkit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I embed and control a WebView in SwiftUI?▼

To embed web content in SwiftUI on iOS 26+, use the native WebKit-for-SwiftUI APIs to create a WebPage, load a URL, and observe page state like title and estimated progress. Implement WebPage.NavigationDeciding to control link routing and keep owned domains in-app.

How do I intercept and control navigation policies in a SwiftUI WebView?▼

You intercept navigation policies in a SwiftUI WebView by implementing the WebPage.NavigationDeciding protocol. This mechanism lets you observe navigation events, keep owned domains in-app, and safely hand off external links to Safari or system flows.

Can I run JavaScript and pass typed arguments in a SwiftUI WebPage?▼

Yes, you can run JavaScript in a SwiftUI WebPage using the callJavaScript API with typed argument passing. You must apply defensive casting to the returned results to safely handle page-driven interactions and integrate them with native UI.

Does WebKit for SwiftUI support custom URL schemes and local bundled HTML?▼

Yes, WebKit for SwiftUI supports local content and custom schemes by registering a URLSchemeHandler. This serves bundled HTML, CSS, and JS offline and handles cancellation semantics for the embedded web view.

When should I use SFSafariViewController or ASWebAuthenticationSession instead of an embedded WebView?▼

You should use SFSafariViewController or ASWebAuthenticationSession as intentional fallbacks when you need dedicated browser authentication or external link viewing rather than an embedded web surface. The Skill provides a migration decision guide for these scenarios.

Why is my WKWebView migration to SwiftUI WebKit not working correctly?▼

Your WKWebView migration to SwiftUI WebKit may fail if you are not using the iOS 26+ WebPage and WebView APIs or missing observable page state. A review checklist helps validate safe patterns, avoid common mistakes, and ensure proper navigation policy control.