0Pricing
Browser Extensions Development (Chrome & Edge) · Lesson

Permissions and Host Matching

Understand how to declare and request necessary permissions, and how host permissions control access to websites.

Permissions and Host Matching is a free Browser Extensions Development (Chrome & Edge) lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Browser Extensions Development (Chrome & Edge) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Extensions Need Permissions

Just like apps on your phone, browser extensions often need special 'permissions' to do their job. These permissions define what your extension can and cannot do.

This system is crucial for user security and privacy. It prevents extensions from accessing information or performing actions they don't need, without your explicit consent.

Two Core Permission Types

In Manifest V3, permissions generally fall into two categories:

  • API Permissions: Access to specific browser features (e.g., managing tabs, saving data).
  • Host Permissions: Access to specific websites (e.g., reading content on example.com).

We'll look at how to declare both in your manifest.json file.

Declaring API Permissions

API permissions are listed under the "permissions" key in your manifest.json. Each string in the array corresponds to a specific browser API.

For example, "storage" lets your extension save user data, and "tabs" allows it to interact with browser tabs (like getting their URLs).

{
  "manifest_version": 3,
  "name": "My Extension",
  "version": "1.0",
  "permissions": [
    "storage",
    "tabs"
  ]
}

The 'activeTab' Permission

The "activeTab" permission is unique. It's an API permission that grants your extension temporary host permissions to the currently active tab.

This access is granted only when the user *invokes* your extension (e.g., clicks its toolbar icon). It's a great way to reduce initial permission warnings, as access is only given when needed.

{
  "manifest_version": 3,
  "name": "ActiveTab Demo",
  "version": "1.0",
  "permissions": [
    "activeTab"
  ]
}

Understanding Host Permissions

Host permissions are crucial for defining which websites your extension can interact with. Without them, your extension cannot read or modify content on web pages.

This is a major security boundary. An extension with host permission for google.com cannot access facebook.com, protecting user data and ensuring privacy.

Specifying Host Permissions

Host permissions are declared in the "host_permissions" array in your manifest.json. You use URL match patterns to specify the domains.

A match pattern like "*://*.example.com/*" means access to all subdomains of example.com over HTTP or HTTPS.

{
  "manifest_version": 3,
  "name": "Host Access",
  "version": "1.0",
  "host_permissions": [
    "*://developer.chrome.com/*",
    "https://www.example.org/*"
  ]
}

Match Pattern Wildcards

Match patterns use special characters:

  • *: Matches any string (except / in scheme/host, or # in path).
  • <all_urls>: A special pattern that matches any URL (http, https, ftp, file). Use this with extreme caution as it grants wide access.

For example, "https://*.google.com/search?*" would match Google search results pages.

Combining API & Host Permissions

Often, your extension will need both API and host permissions. Here's an example for an extension that wants to execute a script on Wikipedia pages.

It needs the "scripting" API permission to run code, and host permission for Wikipedia to define where that code can run.

{
  "manifest_version": 3,
  "name": "Wiki Enhancer",
  "version": "1.0",
  "permissions": [
    "scripting"
  ],
  "host_permissions": [
    "*://*.wikipedia.org/*"
  ]
}

User Consent & Trust

When a user installs your extension, the browser displays a list of all requested permissions. This is their chance to understand what your extension can do.

Always request the minimum necessary permissions. Over-requesting can make users distrust your extension and choose not to install it. Be transparent!

Check Your Understanding

Which statements accurately describe host permissions in Manifest V3 extensions?

Permissions & Host Matching Recap

Great job! You've learned about the vital role of permissions in Manifest V3 extensions.

  • API Permissions: Access browser features (e.g., "storage", "tabs").
  • Host Permissions: Control website access using URL match patterns (e.g., "*://*.google.com/*").
  • "activeTab" is a special API permission that grants temporary host access.
  • Always request the minimum necessary permissions to build user trust.

Understanding these concepts is key to building secure and functional extensions!

Frequently asked questions

Is the “Permissions and Host Matching” lesson free?

Yes — the full text of “Permissions and Host Matching” is free to read here on the web, and the Browser Extensions Development (Chrome & Edge) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Browser Extensions Development (Chrome & Edge) course, upgrade to CoddyKit PRO.

What will I learn in “Permissions and Host Matching”?

Understand how to declare and request necessary permissions, and how host permissions control access to websites. You practise Browser Extensions Development (Chrome & Edge) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Browser Extensions Development (Chrome & Edge)?

No prior experience is required. Browser Extensions Development (Chrome & Edge) on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Permissions and Host Matching” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Browser Extensions Development (Chrome & Edge) lesson?

Yes. Every Browser Extensions Development (Chrome & Edge) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Understanding Manifest V3 Structure
  2. Background Service Workers
  3. Permissions and Host Matching
  4. Action, Icons & the Toolbar Button
← Back to Browser Extensions Development (Chrome & Edge)