You have 2 free member-only stories left this month.

How To Create A Google Chrome Extension With React

Let’s take a look at how we can create a popup Google Chrome extension using React, TypeScript and craco npm package

Artem Diashkin
Nov 29, 2020 · 7 min read

What will be covered in this story:

2. Create React app

npx create-react-app my-app --template typescript
yarn add @types/chrome -D

3. Manifest.json file

INLINE_RUNTIME_CHUNK=false
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
chrome://extensions/

4. Popup width and height restrictions

5. Retrieving active tab’s URL

"permissions": [
"activeTab"
]

6. Manipulating DOM content (content scripts)

Content scripts are files that run in the context of web pages. By using the standard Document Object Model (DOM), they are able to read details of the web pages the browser visits, make changes to them and pass information to their parent extension.

"optional_permissions": [
"<all_urls>"
]

Adding a content script file to our project

6. Overriding Create React App configuration

yarn add @craco/craco

LITSLINK

LITSLINK’s team is sharing their experience

Sign up for LITSLINK Newsletter

By LITSLINK

It's a test newsletter! Take a look.

Artem Diashkin

Written by

Java, Spring, Node.js, AdonisJs, React.js and Flutter developer

LITSLINK

LITSLINK

Hands-on up to date experience sharing of the most skilled & talented software developers right here, right now. Subscribe to learn & understand more about the Software World.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Start a blog