I am interacting with javascript on an html web page with my swift code, but I don't need the actual html view. Is there a way to hide this from showing, but still have it in the render flow?
I cannot use JavaScriptCore because I need things like fetch and npm packages.
I tried WKWebView frame: .zero or CGRect all zero values but this did not work.
So this is why you think the WKWebView needs to be in the view hierarchy to work. An instance of UIViewRepresentabledoes need to be in the view hierarchy in order for the makeUIView and updateUIView methods to be called, but you shouldn't be using UIViewRepresentable at all. It makes no sense to use UIViewRepresentable if you don't want the UIView it wraps to be in the view hierarchy.
Just create an instance of WKWebViewdirectly in one of your model classes and perform whatever work you need with it.