# ShareLink API

Each platform has a standard interface for allowing people to share content from your apps.&#x20;

With watchOS 9, you can now also present the share sheet from within your watch apps.&#x20;

* The new ShareLink view enables presenting that system share sheet from within your app.&#x20;
* You can simply provide it with the content to be shared and a preview to use in the share sheet, and it automatically creates a standard share icon button.&#x20;
* On tap, it presents the standard share sheet to send off the content.&#x20;

{% tabs %}
{% tab title="Link" %}
in `WinesTab`

**import** Charts

**import** SwiftUI

\


**struct** Wines: Identifiable {

&#x20;   **var** name: String

&#x20;   **var** sales: Int

&#x20;  &#x20;

&#x20;   **var** id: String { name }

}

\


**let** sales: \[Wines] = \[

&#x20;   .init(name: "Margaux", sales: 500),

&#x20;   .init(name: "Médoc", sales: 460),

&#x20;   .init(name: "Blaye", sales: 300),

&#x20;   .init(name: "St Estèphe", sales: 290),

&#x20;   .init(name: "Sauternes", sales: 250),

&#x20;   .init(name: "Pessac-Léognan", sales: 20)

]

\


**struct** WinesTab: View {

&#x20;   @Environment(\\.openWindow) **var** openWindow

&#x20;  &#x20;

&#x20;   **var** body: **some** View {

&#x20;       ZStack {

&#x20;           Chart(sales) { element **in**

&#x20;               BarMark (

&#x20;                   x: .value("Sales", element.sales),

&#x20;                   y: .value("Name", element.name)

&#x20;               )

&#x20;           }

&#x20;       }

&#x20;       .padding(20)

&#x20;       .toolbar {

&#x20;           Button {

&#x20;               openWindow(id: "Sales")

&#x20;           } label: {

&#x20;               Image(systemName: "dollarsign")

&#x20;           }

&#x20;       }

&#x20;       <mark style="color:orange;">.toolbar {</mark>

&#x20;           <mark style="color:orange;">ShareLink(item: URL(string: "https://frenchkit.fr/")!) {</mark>

&#x20;               <mark style="color:orange;">Label("Share", image: "icon-fk")</mark>

&#x20;           <mark style="color:orange;">}.padding()</mark>

&#x20;       <mark style="color:orange;">}</mark>

&#x20;   }

}

\


**struct** WinesTab\_Previews: PreviewProvider {

&#x20;   **static** **var** previews: **some** View {

&#x20;       WinesTab()

&#x20;   }

}
{% endtab %}
{% endtabs %}

<figure><img src="https://1097234039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj3vybST3gHmvCcIboaVS%2Fuploads%2FmvonGJw3hdmomOxAqjVT%2Ficon-fk.png?alt=media&#x26;token=8b74d216-f0fe-43b3-841c-a63b689dc64b" alt=""><figcaption><p>icon-fk</p></figcaption></figure>
