Google Chrome Extension - ReactJS
An extension is a zipped bundle of files (HTML, CSS, Javascript, images etc). It allows us to add functionality to chrome without deeply diving into native code. They can interact with servers through XMLHttpRequest (ajax) and if we wish to read (or modify) HTML from existing web page then content script allows us to do so.
Google has already done a great job with documentation and you can find a "Getting Started" guide here.
Google has already done a great job with documentation and you can find a "Getting Started" guide here.
Let's Start
We are going to develop a simple extension which will show us the weather for selected city.
We will be developing a single page application using ReactJS which will target weather API using XMLHttpRequest and then with help of plain old javascript we will process the JSON response to update UI.
Packaging
From the "app" folder you can extract the code for our single page application. This is the core of application and all UI logic is managed here. Next step for us is to create a manifest file which will look as below
{ "manifest_version": 2, "name": "Weather Application", "description": "This extension will show current weather for selected city",
"version": "1.0", "browser_action": { "default_icon": "icon.png", "default_popup": "app/app.html" } }
A manifest file can have more attributes depending on application requirement (for a complete set of properties please refer to this link) but to create a simple extension we only need to consider below mentioned properties
- name - This is the name of application that will be displayed under you application in extension page (and in chrome store). This name will also come as tool tip when someone hover over extension.
- description - This is sample description of application. It helps its user understand what the extension is developed for.
- version - This is application version and should be updated with each major or minor release to help others understand which version they are using.
- default-icon - This is the icon that is displayed in chrome when extension is added.
- default-popup - This defines the entry point for application. When we click on extension icon, this HTML page is loaded first. In our case this will be the app.html file which loads reactJS code for further execution.
Load Extension
To test our new extension we need to visit chrome://extensions in a chrome browser. On the top right corner of this page there will be a small check box with "Developer mode" as text. We need to enable this to load our package.
Once enabled we will have three extra options as highlighted in screen capture below
- Load unpacked extension
- Pack extension
- Update extensions now
Click on "Load unpacked extension" and locate the folder with extension code. Click on OK and this should add the extension. You will have a confirmation as shown in below image
To publish this application on chrome web store please check this document.
Note: As you will notice in the source code we are not using JSX. Babel executes inline script in-order to convert JSX code to Javascript. This violates Content Security Policy directive of chrome extension. You can always use JSX to Javsacript converter if you are less familiar with template syntax in Javascript.
Excellent blog about reactjs admin. I have bookmarked this page for my reference. Share more like this.
ReplyDeleteReactJS Certification | ReactJS course in Chennai
Informative post, thanks for taking time to share this page.
ReplyDeleteAngularjs Training in Chennai
Angularjs course in Chennai
Angularjs Training
Angularjs Training institute in Chennai
AWS Training in Chennai
AWS course in Chennai
ReplyDeleteThanks for sharing this post.Keep sharing more like this.
oceanofquotes
Guest posting sites
Informative post indeed, I’ve being in and out reading posts regularly and I see alot of engaging people sharing things and majority of the shared information is very valuable and so, here’s my fine read.
ReplyDeleteclick here code html
click here co 2lz4drob
click here code
click here chat
click here to check results
This is good information and really helpful for the people who need information about this.
ReplyDeletevisiting card price in india
printed mugs online india
laptop rental in chennai
laptop for rent in chennai price
company formation in chennai
company registration in chennai
It is an excellent blog. Your post is very good and unique. I eagerly waiting for your new post. Thanks for sharing keep sharing more good blogs.
ReplyDeleteDOT NET Training in Bangalore
DOT NET Training in Chennai
DOT NET Training Institutes in Bangalore
DOT NET Course in Bangalore
Best DOT NET Training Institutes in Bangalore
DOT NET Institute in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
PHP Training in Bangalore
ReplyDeleteAmazing Post. keep update more information.
Selenium Training in Chennai
Selenium Training in Bangalore
Selenium Training in Coimbatore
Selenium Course in Bangalore
Best Selenium Training in Bangalore
Selenium training in marathahalli
Selenium training in Btm
Ethical Hacking Course in Bangalore
Tally Course in Chennai
This Blog is really informative!! keep update more about this…
ReplyDeleteAviation Courses in Bangalore
Air Hostess Training in Bangalore
Airport Management Courses in Bangalore
Ground Staff Training in Bangalore
Best Aviation Academy in Bangalore
Air Hostess Training Institute in Bangalore
Airline and Airport Management Courses in Bangalore
This was an excellent post and very good information provided, Thanks for sharing.
ReplyDeleteArtificial Intelligence Training in Chennai
AI classes in Chennai
Artificial Intelligence Course in Chennai
Angular course in Bangalore
Angularjs Training in Marathahalli
AngularJS Training in Chennai
Web Designing course in Bangalore
Salesforce Training in Bangalore
Best Python Training in Bangalore
Python Classes in Chennai
Python Classes in Coimbatore
Best Institute for Python in Hyderbad
This was an excellent info being posted. This would definitely help the needed ones to a greater extend.
ReplyDeleteastrologers in india
astrology online
best astrologer in andhra pradesh
best astrology online
astrology
famous astrologer in andhra pradesh
best astrologer near me
top 10 astrologers in andhra pradesh