<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SafariServices",
  "identifier" : "/documentation/SafariServices/SFSafariWindow/openTab(with:makeActiveIfPossible:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Safari Services"
    ],
    "preciseIdentifier" : "c:objc(cs)SFSafariWindow(im)openTabWithURL:makeActiveIfPossible:completionHandler:"
  },
  "title" : "openTab(with:makeActiveIfPossible:completionHandler:)"
}
-->

# openTab(with:makeActiveIfPossible:completionHandler:)

Opens a tab at the end of the tab bar.

```
func openTab(with url: URL, makeActiveIfPossible activateTab: Bool, completionHandler: (@Sendable (SFSafariTab?) -> Void)? = nil)
```

## Parameters

`url`

The URL to navigate to.

`activateTab`

<doc://com.apple.documentation/documentation/Swift/true> to make the tab active; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

`completionHandler`

A block called after the tab is opened.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func openTab(with url: URL, makeActiveIfPossible activateTab: Bool) async -> SFSafariTab?
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

If the extension cannot access the URL, no tab is opened.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)