What are the best practices for structuring a large Manifest V3 browser extension? #203947
🏷️ Discussion TypeQuestion 💬 Feature/Topic AreaVerification Help & Guidance Hi everyone,I'm building a fairly large Manifest V3 browser extension with multiple features, including a popup, options page, background service worker, content scripts, and shared utilities. As the project grows, I'm finding it harder to keep the codebase organized and maintainable. I'm curious how experienced developers structure large MV3 projects. Some questions I have:
I'd appreciate any examples or recommendations from production projects. Thanks! |
Replies: 1 comment
|
For larger MV3 projects, I usually separate the extension into feature-based folders instead of page-based folders. For example: A few practices that have helped:
If the project becomes reusable across multiple extensions, extracting shared code into a separate package or monorepo can also work well. The exact structure depends on the project's size, but keeping contexts isolated and sharing only common logic has made my MV3 projects much easier to maintain. Also don't forget to checkout https://github.com/ZaheerAhmedkhan65/mv3-forge |
For larger MV3 projects, I usually separate the extension into feature-based folders instead of page-based folders.
For example:
A few practices that have helped:
sharedfolder so it can be reused by all extension contexts.chrome.runtime.sendMessage()everywhere.