How to make a simple back button.

So I am trying to control the wkwebview content within my app. When I try the following code>

  var backButton: some View {
        Button(action: {
            webView.goBack()
            // Add your back button action here
        }, label: {
            Image(systemName: "arrow.uturn.backward")
                .font(.title)
        })
        .navigationBarBackButtonHidden(true)
    }

I get webView out of scope.

This is how I have webView implimented

 struct WebView: UIViewRepresentable {
        let url: URL
        let preferences = WKPreferences()
        
        let useragent = WKWebViewConfiguration()
        
        
        func makeUIView(context: Context) -> WKWebView {
            @State var webView = WKWebView()
            let request = URLRequest(url: url)
            
            useragent.applicationNameForUserAgent = "Version/1.2 LavaRock/1.2"
            useragent.allowsAirPlayForMediaPlayback = true
            useragent.allowsInlineMediaPlayback = true
            useragent.allowsPictureInPictureMediaPlayback = true
//
            
            preferences.isFraudulentWebsiteWarningEnabled = true
            preferences.isSiteSpecificQuirksModeEnabled = true
            preferences.isElementFullscreenEnabled = true
            webView.allowsBackForwardNavigationGestures = true
//            webView.configuration.allowsPictureInPictureMediaPlayback = true
            webView.customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Version/1.2 LavaRock/1.2"
            
            
            webView.load(request)
            
            
            return webView
        }
        
        func updateUIView(_ uiView: WKWebView, context: Context) {
            // Handle view updates if needed
        }
    }
    

How should create the button?

How to make a simple back button.
 
 
Q