Documentation Index
Fetch the complete documentation index at: https://mintlify.com/frol/near-connect-ios/llms.txt
Use this file to discover all available pages before exploring further.
BridgeWebViewContainer
BridgeWebViewContainer is a SwiftUI UIViewRepresentable that wraps the persistent WKWebView owned by NEARWalletManager. This allows the same WebView instance to be shown and hidden across different sheets without losing JavaScript state or the near-connect wallet session.
Declaration
Overview
This component is primarily used internally byWalletBridgeSheet, but you can use it directly if you need custom UI layouts around the wallet WebView.
The key benefit of BridgeWebViewContainer is that it preserves the WebView’s state across different presentations. The WebView instance remains in memory and maintains its JavaScript context, ensuring wallet sessions persist even when the UI is dismissed and re-presented.
Initialization
The persistent WKWebView instance from
NEARWalletManager.bridgeWebViewUsage
Basic Usage with NEARWalletManager
Custom Sheet with BridgeWebViewContainer
Implementation Details
The container handles WebView lifecycle and layout:- View Creation: Wraps the WebView in a UIView container with proper sizing
- Layout: Configures autoresizing masks for flexible width/height
- Safe Area: Disables content inset adjustment for full-screen display
- Re-parenting: Safely moves the WebView between containers when the view updates
The WebView instance is owned by
NEARWalletManager and should not be released or modified outside of the manager. The container simply presents it in the SwiftUI view hierarchy.Technical Notes
WebView Persistence
The sameWKWebView instance can be safely moved between different BridgeWebViewContainer instances. SwiftUI’s updateUIView method ensures the WebView is correctly re-parented when needed.
JavaScript State
Because the WebView persists across presentations:- Wallet connections remain active
- JavaScript variables and state are preserved
- No need to reload the near-connect library
- Faster subsequent operations
Memory Management
The WebView is retained byNEARWalletManager for its entire lifetime. The container only holds a reference and does not manage the WebView’s lifecycle.
When to Use
UseBridgeWebViewContainer when:
- You need a custom wallet UI layout
- You want to embed the wallet in a specific screen design
- You need more control over the presentation flow
WalletBridgeSheet when:
- You want the standard full-screen wallet experience (recommended)
- You don’t need custom UI around the wallet
- You want automatic flow management
Related APIs
- NEARWalletManager - Main wallet manager class
- WalletBridgeSheet - Ready-to-use wallet sheet component
- Wallet Connection - Guide to connecting wallets