Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ browser-compat: webextensions.api.runtime.getManifest
sidebar: addonsidebar
---

Get the complete [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file, deserialized from JSON to an object.
Get the object representation of [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file. This representation is produced from browser-internal data structures and may differ from what would be produced by running `JSON.parse()` on the actual file within extension.

## Syntax

Expand Down Expand Up @@ -37,6 +37,10 @@ console.log(manifest.name);

{{Compat}}

## See also

- {{WebExtAPIRef("runtime.getVersion()")}} method which returns value of [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) manifest key

> [!NOTE]
> This API is based on Chromium's [`chrome.runtime`](https://developer.chrome.com/docs/extensions/reference/api/runtime#method-getManifest) API. This documentation is derived from [`runtime.json`](https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json) in the Chromium code.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: runtime.getVersion()
slug: Mozilla/Add-ons/WebExtensions/API/runtime/getVersion
page-type: webextension-api-function
browser-compat: webextensions.api.runtime.getVersion
sidebar: addonsidebar
---

Returns the extension's version as declared by developer in the [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) [manifest](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) key.

## Syntax

```js-nolint
browser.runtime.getVersion()
```

### Parameters

None.

### Return value

A `string` containing the extension's version as declared in the manifest.

## Examples

Get the extension version string:

```js
const version = browser.runtime.getVersion();
console.log(version);
```

{{WebExtExamples}}

## Browser compatibility

{{Compat}}

## See also

- {{WebExtAPIRef("runtime.getManifest()")}} method which returns representation of the entire manifest
- Manifest [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) key
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ It also provides messaging APIs enabling you to:
- {{WebExtAPIRef("runtime.getFrameId()")}}
- : Gets the frame ID of any window global or frame element.
- {{WebExtAPIRef("runtime.getManifest()")}}
- : Gets the complete [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file, serialized as an object.
- : Gets the object representation of complete [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file.
- {{WebExtAPIRef("runtime.getURL()")}}
- : Given a relative path from the [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) to a resource packaged with the extension, returns a fully-qualified URL.
- {{WebExtAPIRef("runtime.getVersion()")}}
- : Gets the extension version string from [manifest.json](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) field. The returned version may be distinct from the actual string in the file, because it may be parsed and then serializad by the browser.
- {{WebExtAPIRef("runtime.setUninstallURL()")}}
- : Sets a URL to be visited when the extension is uninstalled.
- {{WebExtAPIRef("runtime.reload()")}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ You see this in the console log:
## Browser compatibility

{{Compat}}

## See also

- {{WebExtAPIRef("runtime.getVersion()")}} method
- [`version_name`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version_name) manifest key
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ sidebar: addonsidebar
</tbody>
</table>

In addition to the [version](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) field, which is used for update purposes, [version_name](https://developer.chrome.com/docs/extensions/reference/manifest/version) can be set to a descriptive version string and will be used for display purposes if present.
In addition to the [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) field, which is used for update purposes, `version_name` can be set to a descriptive version string and will be used for display purposes if present.

If no **version_name** is present, the **version** field will be used for display purposes as well.
If no `version_name` is present, the `version` field will be used for display purposes as well.

## Browser compatibility

{{Compat}}

## See also

- [`version`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version) manifest key