<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: stefàn</title>
    <description>The latest articles on DEV Community by stefàn (@stayfun_).</description>
    <link>https://dev.to/stayfun_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F377037%2F172d80db-a9a3-46ad-b53e-a98617c5db62.jpg</url>
      <title>DEV Community: stefàn</title>
      <link>https://dev.to/stayfun_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stayfun_"/>
    <language>en</language>
    <item>
      <title>Building a Modern React Chrome Extension with a New Framework</title>
      <dc:creator>stefàn</dc:creator>
      <pubDate>Tue, 31 May 2022 13:59:14 +0000</pubDate>
      <link>https://dev.to/plasmo/building-a-modern-react-chrome-extension-with-a-new-framework-4ho1</link>
      <guid>https://dev.to/plasmo/building-a-modern-react-chrome-extension-with-a-new-framework-4ho1</guid>
      <description>&lt;p&gt;When I first started building Chrome extensions, I was so annoyed with the boilerplate. &lt;/p&gt;

&lt;p&gt;It was frustrating to configure the &lt;code&gt;manifest.json&lt;/code&gt;, pointing it to the correct files. You had to read at least 4 blog posts to figure out how to do it correctly. The annoyance compounded if you tried to use modern JavaScript frameworks like React. Now you needed to deal with Webpack, and figure out how that played into the &lt;code&gt;manifest.json&lt;/code&gt; story. &lt;/p&gt;

&lt;p&gt;We decided to tackle this problem by building a framework for browser extension development called &lt;a href="https://docs.plasmo.com" rel="noopener noreferrer"&gt;Plasmo&lt;/a&gt;. It's a different way of thinking about browser extensions, and if you're used to building extensions, some things might look a bit weird.&lt;/p&gt;

&lt;p&gt;If you want to follow along, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm dlx plasmo init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looking at the directory &lt;code&gt;plasmo init&lt;/code&gt; generated, you might notice there is no &lt;code&gt;manifest.json&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg3xl8kil86s15xqkzch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg3xl8kil86s15xqkzch.png" alt="Plasmo directory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is one of the key features of the Plasmo Framework -- we auto-generate the &lt;code&gt;manifest.json&lt;/code&gt; so you can focus on building cool stuff rather than caring about where to point &lt;code&gt;content_scripts&lt;/code&gt; to, and what the schema format should look like.&lt;/p&gt;

&lt;p&gt;The idea is simple: you add a file called &lt;code&gt;popup.tsx&lt;/code&gt; exporting a React component, and Plasmo will understand it's a popup page. It'll register it in the manifest and write the code to automatically mount the component into your popup view.&lt;/p&gt;

&lt;p&gt;The same is true for &lt;code&gt;content.ts&lt;/code&gt;, &lt;code&gt;background.ts&lt;/code&gt;, and &lt;code&gt;options.tsx&lt;/code&gt;. The framework understands what these files are, and automatically builds the manifest with them in mind. &lt;/p&gt;

&lt;p&gt;If you have multiple scripts, you can use &lt;code&gt;contents/&lt;/code&gt;, &lt;code&gt;options/&lt;/code&gt;, and &lt;code&gt;popups/&lt;/code&gt; directories to get the same effect. &lt;/p&gt;

&lt;h2&gt;
  
  
  Key Principles:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  No manifest.json file
&lt;/h3&gt;

&lt;p&gt;We strongly believe the manifest.json file is a &lt;a href="https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/" rel="noopener noreferrer"&gt;leaky abstraction&lt;/a&gt;. That's why we built the framework to generate as much of the manifest as possible. &lt;/p&gt;

&lt;p&gt;We've still got a bit of a way to go, but we've automated a large chunk of it out.&lt;/p&gt;

&lt;h3&gt;
  
  
  It's good to have opinions
&lt;/h3&gt;

&lt;p&gt;This framework is not for everybody, and that's completely okay. Our goal is not to make a framework that caters to everyone's needs. Instead, we're focusing on people who want to build production-grade extenisons using React quickly. &lt;/p&gt;

&lt;p&gt;If someone wanted to build a minimalist extension that used vanilla Javascript, this framework would not be for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  MV3 Only
&lt;/h3&gt;

&lt;p&gt;Manifest version 3 is the future. Let's embrace it and build good tooling around it to enable people to build amazing products. &lt;/p&gt;

&lt;h2&gt;
  
  
  Docs
&lt;/h2&gt;

&lt;p&gt;Check out our &lt;a href="https://docs.plasmo.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt; to see other cool features we have. We're constantly iterating and improving, so if you have feedback, would love to hear it! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
  </channel>
</rss>
