webkit_skill

This skill enables embedding and controlling web content in SwiftUI apps using WebView and WebPage for navigation, JS interop, and customization.
  • Swift

56

GitHub Stars

4

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill rshankras/claude-code-apple-skills --skill webkit

  • javascript-advanced.md13.1 KB
  • navigation.md12.8 KB
  • SKILL.md5.8 KB
  • webview-basics.md8.2 KB

Overview

This skill provides practical guidance for embedding and controlling web content in SwiftUI apps using WebView and WebPage. It covers loading URLs or HTML, navigation control, JavaScript interop, snapshots/PDF export, and common configuration needs like private browsing and custom user agents.

How this skill works

WebView displays web content in a SwiftUI view while WebPage is an observable controller that manages loading, navigation state, and configuration. You create a WebPage to load URLRequests, HTML strings, or data blobs, observe navigation events for loading and errors, execute JavaScript safely with argument binding, and customize behavior via WebPage.Configuration and WebsiteDataStore options.

When to use it

  • Embedding a webpage or HTML content inside a SwiftUI app
  • Needing navigation control (back, forward, reload) or loading state
  • Executing JavaScript from Swift and receiving results or messages
  • Intercepting or cancelling navigation and handling custom URL schemes
  • Capturing snapshots, exporting PDFs, or exporting web archives

Best practices

  • Use WebPage + WebView(page) when you need navigation, events, or programmatic control
  • Always import both SwiftUI and WebKit when using WebPage APIs
  • Observe page.currentNavigationEvent for loading indicators and error handling
  • Wait for a .finished navigation event before calling callJavaScript to ensure the DOM is ready
  • Use WebsiteDataStore.nonPersistent() for private browsing to avoid saving user data
  • Pass JavaScript arguments via the arguments: parameter to avoid injection and improve debugging

Example use cases

  • A help center screen that loads remote docs and supports back/forward navigation
  • An embedded dashboard that calls page JavaScript to update charts and reads results back to Swift
  • A privacy-focused view that uses a nonPersistent data store and a custom user agent
  • A feature that snapshots a rendered invoice page and exports it as a PDF
  • Intercepting navigation to open payment links in an external app or handle custom scheme callbacks

FAQ

No. Use WebView(url:) for simple, read-only display. Use WebPage when you need navigation events, programmatic control, or configuration options.

How do I safely run JavaScript and pass values?

Use callJavaScript with the arguments: parameter and wait until the page navigation event is .finished to avoid DOM timing issues and injection risks.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational