---
title: "action(for:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensioncontext/action(for:)"
---

# action(for:)

Retrieves the extension action for a given tab, or the default action if nil is passed.

## Declaration

```swift
func action(for tab: (any WKWebExtensionTab)?) -> WKWebExtension.Action?
```

## Parameters

- `tab`: The tab for which to retrieve the extension action, or nil to get the default action.

## Discussion

Discussion The returned object represents the action specific to the tab when provided; otherwise, it returns the default action. The default action is useful when the context is unrelated to a specific tab. When possible, specify the tab to get the most context-relevant action.

## See Also

### Related Documentation

- [performAction(for:)](webkit/wkwebextensioncontext/performaction(for:).md)
