<?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: Shahid Shaikh</title>
    <description>The latest articles on DEV Community by Shahid Shaikh (@__shahidshaikh).</description>
    <link>https://dev.to/__shahidshaikh</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%2F125461%2F188b0498-0d29-4574-84b3-c3d977a08293.jpg</url>
      <title>DEV Community: Shahid Shaikh</title>
      <link>https://dev.to/__shahidshaikh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/__shahidshaikh"/>
    <language>en</language>
    <item>
      <title>How to make a Chrome Extension using React JS</title>
      <dc:creator>Shahid Shaikh</dc:creator>
      <pubDate>Sun, 17 Jul 2022 13:37:30 +0000</pubDate>
      <link>https://dev.to/__shahidshaikh/how-to-make-a-chrome-extension-using-react-js-41bj</link>
      <guid>https://dev.to/__shahidshaikh/how-to-make-a-chrome-extension-using-react-js-41bj</guid>
      <description>&lt;p&gt;A lot of us know how to use React JS to create web apps. Given that, we can use this same knowledge to create Chrome extensions as well. In this post, I'll be telling you simple steps on how you can create and publish chrome extensions using React JS.&lt;/p&gt;

&lt;p&gt;Prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React JS (create-react-app)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To set up your application, we can use create-react-app. If you're hearing about it for the first time, you can head over to their official &lt;a href="https://reactjs.org/docs/create-a-new-react-app.html"&gt;documentation&lt;/a&gt; to learn more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app my-chrome-extension-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the above command, create-react-app will setup a new react app for you. Head over to &lt;code&gt;my-chrome-extension-name&lt;/code&gt; folder and open your preferred code editor.&lt;/p&gt;

&lt;p&gt;Now, to run your newly created react app, run the below command which will spin up a local server for you&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let's add some HTML and CSS
&lt;/h2&gt;

&lt;p&gt;Now, head over to &lt;code&gt;App.js&lt;/code&gt; file inside the src folder. Here's you'll see a lot of predefined code. Remove all the code inside &lt;code&gt;&amp;lt;div className="App"&amp;gt;&lt;/code&gt; and replace with your own HTML. In our case, we are just adding a heading tag with 'Hello World' text. The contents of your file should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let's remove content inside App.css file and replace with some basic styling as mentioned below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;400px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt; &lt;span class="nb"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#2999f5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#1859d1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.App&lt;/span&gt; &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Making this App work with Chrome
&lt;/h2&gt;

&lt;p&gt;We are done with the changes that were required inside the react app. Let's add a few more things to make it work with chrome.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Inside the root folder &lt;code&gt;my-chrome-extension-name&lt;/code&gt;, create a new file named '.env.production' (without quotes, but make sure to add full stop at the start) and add the below line inside of it&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;INLINE_RUNTIME_CHUNK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;without this line, you will receive a 'Content Security Policy' error when importing the extension inside chrome. Basically, this error arises as Chrome (or almost any modern browser) will not allow inline scripts to get executed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to public folder and replace the contents of 'manifest.json' with the below code:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"First Chrome Extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"This is a First Chrome Extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"manifest_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Author Name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"16"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"favicon.ico"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"48"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"favicon.ico"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"128"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"favicon.ico"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"default_popup"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.html"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;You can read about different values and what they do inside the above JSON &lt;a href="https://developer.chrome.com/docs/extensions/mv3/intro/"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now, run the below command to compile our extension&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This will create a build folder inside our extensions folder. We will have to import this build folder inside chrome which we will do in the next steps.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Importing our extension inside Chrome
&lt;/h2&gt;

&lt;p&gt;We have now completed all the steps to create our own chrome extension. All we have to do is now to import the same inside Chrome. Please follow the below steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Chrome&lt;/li&gt;
&lt;li&gt;Go to chrome://extensions/.&lt;/li&gt;
&lt;li&gt;At the top right, turn on Developer mode.&lt;/li&gt;
&lt;li&gt;Click Load unpacked.&lt;/li&gt;
&lt;li&gt;Find and select the 'build' folder inside your chrome extension's folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt; You must now be able to see your chrome extension inside chrome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to Note
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Whenever you make changes to your extension, you will have to run 'npm run build' command each time and reload the extension inside chrome to see the changes&lt;/li&gt;
&lt;li&gt;To publish your extension to Chrome's web store, you can follow the steps mentioned &lt;a href="https://developer.chrome.com/docs/webstore/publish/"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;I have created a repository with the same steps mentioned above. You can use this repo to create your own extension. Here's the &lt;a href="https://github.com/shahidshaikhs/react-chrome-extension-starter"&gt;Github Link&lt;/a&gt; to the same&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I hope this was helpful. You can reach out to me on my email address "&lt;a href="mailto:shahid.sk27595@gmail.com"&gt;shahid.sk27595@gmail.com&lt;/a&gt;" in case of any queries.&lt;/p&gt;

&lt;p&gt;Thank you! 💖&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>chrome</category>
      <category>chromeextension</category>
      <category>react</category>
    </item>
    <item>
      <title>Hello World! </title>
      <dc:creator>Shahid Shaikh</dc:creator>
      <pubDate>Tue, 07 May 2019 02:49:02 +0000</pubDate>
      <link>https://dev.to/__shahidshaikh/hello-world-1din</link>
      <guid>https://dev.to/__shahidshaikh/hello-world-1din</guid>
      <description>&lt;p&gt;My name is Shahid Shaikh and I have been coding for the past 4 years now. I live in one of the busiest yet interesting city in India known as Mumbai. &lt;/p&gt;

&lt;p&gt;I started my journey by creating Icon Packs for Android Devices in 2015, where I used Open Source Icon Packs dashboard and compiled it along with icons that I made using Photoshop. We had a small community of icon pack designers on Google Plus (RIP) contributing and supporting each other's work. &lt;/p&gt;

&lt;p&gt;Later in 2016, I decided to learn more about Android Development and took a few basic to an advanced course on Udacity. In a year's time, I was able to design and develop multiple applications on the Play Store. One of my favorite and successful app is called as "Scrittor". It's a simple/minimal note-taking application. &lt;/p&gt;

&lt;p&gt;In 2017, I started working as a Web Solution Specialist in an MNC called "Endurance Internation Group". I was fortunate enough to work on some really great web development projects where my contribution was in the Front End. I learned a lot about HTML, CSS (including SASS) and JS. &lt;/p&gt;

&lt;p&gt;During this time my interest changed from Mobile to Web Development team and I am very excited to learn more about the same. One thing which overwhelms me about web development is the number of technologies that are being introduced each week. &lt;/p&gt;

&lt;p&gt;Currently, I am learning Node JS along with Express and MongoDB from Udemy and it has been such an interesting journey. &lt;/p&gt;

&lt;p&gt;Also, English is not my first language nor I am good at writing (need to fix this) and I am sure you have learned that by now.🤭 &lt;/p&gt;

&lt;p&gt;I am hoping to learn a lot more via the "Dev.to" community and contribute to the same. &lt;/p&gt;

&lt;p&gt;Thank you for reading 😊&lt;/p&gt;

</description>
      <category>introduction</category>
      <category>web</category>
      <category>android</category>
      <category>development</category>
    </item>
  </channel>
</rss>
