Developers

Chrome Extension Migrate Manifest v3 from v2

A guide to converting Manifest V2 extensions to Manifest V3 extensions. Created by Exmo – a monetization platform for browser extensions.

In November 2020, Chrome unveiled Manifest V3, marking a significant transition from the long-standing Manifest V2 utilized by extensions. This transition carries substantial implications, particularly considering the array of new features introduced in V3. This tutorial will outline the necessary steps to migrate seamlessly from Manifest V2 to V3.

Note: Manifest V3 is typically supported in Chrome 88 or later versions. For extension features introduced in subsequent Chrome releases, please refer to the API reference documentation for compatibility details. If your extension relies on a particular API, you can define a minimum Chrome version requirement in the manifest file.

The format required for the manifest.json file varies slightly between Manifest V3 and Manifest V2. While this page focuses solely on changes specific to the manifest.json file, it’s important to note that several changes to scripts and pages will also necessitate adjustments to the manifest. These modifications are addressed alongside the migration tasks that require them.


Change the manifest version number

Change the value of the “manifest_version” field from 2 to 3.

Manifest V2

{
  ...
  "manifest_version": 2
  ...
}

Manifest V3

{
  ...
  "manifest_version": 3
  ...
}

Update host permissions

In Manifest V3, host permissions are now specified as a separate field and are not included within the “permissions” or “optional_permissions” sections.

Content scripts continue to be defined under “content_scripts.matches“. For further details, refer to the “Inject with static declarations” section.

Manifest V2

{
  ...
  "permissions": [
    "tabs",
    "bookmarks",
    "https://exmo.tech/",
  ],
  "optional_permissions": [
    "unlimitedStorage",
    "*://*/*",
  ]
  ...
}

Manifest V3

{
  ...
  "permissions": [
    "tabs",
    "bookmarks"
  ],
  "optional_permissions": [
    "unlimitedStorage"
  ],
  "host_permissions": [
    "https://exmo.tech/",
  ],
  "optional_host_permissions": [
    "*://*/*",
  ]
  ...
}

Update web accessible resources

The approach to handling web accessible resources has been updated in Manifest V3 to enhance security and limit exposure. Previously, in Manifest V2, the “web_accessible_resources” field allowed extensions to be detected by websites and potentially exploited by attackers if resources were exposed. This raised concerns related to fingerprinting or unintended resource access.

In Manifest V3, access to resources within extensions is restricted, and you now define permissions more selectively. Instead of simply listing files, you provide an array of objects, each mapping a set of resources to specific URLs or extension IDs.

For a clearer understanding, let’s compare the handling of web accessible resources between Manifest V2 and Manifest V3:

In Manifest V2:

  • Specified resources were accessible to all websites by default.

In the Manifest V3 code snippet below:

  • Resources are restricted to only be accessible to https://example.com.
  • Certain images are made available to all websites.

For further details, refer to the documentation on Web accessible resources and Match patterns.

Manifest V2

{
  ...
  "web_accessible_resources": [
    "images/*",
    "style/extension.css",
    "script/extension.js"
  ],
  ...
}

Manifest V3

{
  ...
    "web_accessible_resources": [
    {
      "resources": [
        "images/*"
      ],
      "matches": [
        "*://*/*"
      ]
    },
    {
      "resources": [
        "style/extension.css",
        "script/extension.js"
      ],
      "matches": [
        "https://example.com/*"
      ]
    }
  ],
  ...
}

Continue reading:

Frequently Asked Questions

What is Manifest V3, and why is it important?

Manifest V3 (MV3) is the latest version of the Chrome extension platform, introduced by Google in November 2020. It brings significant changes to how extensions are developed and function, with a focus on improved security, privacy, and performance. Upgrading to MV3 ensures that your extension complies with the latest standards and takes advantage of new features.

How do I change the manifest version number from V2 to V3?

To upgrade your extension to Manifest V3, simply change the “manifest_version” field in your manifest.json file from 2 to 3.

How should I update host permissions in Manifest V3?

In MV3, host permissions are specified separately from general permissions. You need to move the URLs from the “permissions” and “optional_permissions” sections to the new “host_permissions” and “optional_host_permissions” sections.

How do I migrate to a service worker?

To migrate to a service worker, you need to define it in your manifest.json and update your background script logic to use the service worker.

How can I improve extension security with Manifest V3?

Manifest V3 improves security by enforcing stricter content security policies, disallowing the execution of arbitrary code, and requiring that all code be included within the extension package. You should review your extension’s use of external scripts and ensure they are bundled with your extension or use sandboxed iframes where necessary.

Where can I find more detailed instructions and examples?

Detailed instructions and examples can be found in the Chrome Extension documentation and API reference. The Chrome Extension Samples repository also provides practical examples and code snippets to help you migrate and update your extension.

Ruslana Gonsalez

As an Exmo Product Manager, my role involves overseeing the development and enhancement of our monetization platform. I lead a team of specialists, strategizing innovative features and improvements to optimize user experience. My responsibilities include conducting market research, gathering user feedback, and collaborating with developers to ensure Exmo remains at the forefront of browser extension monetization.

Recent Posts

3 Reasons Why Affiliate Ads is Your Secret Weapon for Monetizing Extensions (Without Annoying Users or Messing Up Your Code)

You’ve spent tons of time on your extension: optimized the code, squashed bugs, polished the…

5 months ago

A Line of Code is Not a Scam, But a Legitimate Monetization Tool Aligned with Webstore Policies

In the browser extension development community, particularly among Firefox users, there is a bias against…

5 months ago

Monetizing Browser Extensions: Integrating Affiliate Marketing via SDK. A Guide for Extension Developers

Affiliate marketing is a powerful tool for monetizing browser extensions. It requires no direct costs…

7 months ago

Monetize Browser Extensions with Affiliate Marketing: Turn Your Project into a Stable Income Source

Your browser extension already delivers value to users, but have you considered making it a…

7 months ago

How to Make Your Extension Start Generating Revenue Right Now

Creating a successful extension is a significant achievement, but one of the toughest challenges begins…

7 months ago

5 Reasons Why Developers Should Use Affiliate Marketing to Monetize Extensions

Developers looking for innovative ways to generate revenue can turn to Affiliate Marketing to Monetize…

7 months ago

This website uses cookies to enhance your browsing experience. By continuing to use our site, you consent to our use of cookies.

Terms and Conditions