How to Open a Link with SwiftUI
Adding a control for navigating to a URL
2 min readJul 5, 2022
Note: This tutorial is also available in video form on YouTube.
In this short tutorial, I’ll show you how you can add a button that opens a URL in a browser using SwiftUI. To do this, we can use SwiftUI’s Link, which will add a control to navigate to a given URL.
Let’s start with a simple text view that will look similar to a hyperlink. Inside a SwiftUI View, we can initialize a Link with a title string and a destination URL, like so:
Running the app will give the following result: