Google Chrome extension built using React.js 18 and Vite 5.
The idea of this extension is to download messages from API, store them in storage and display whenever popup opens.
- Install and build the project:
git clone https://github.com/delasy/messages-chrome-extension.git
cd messages-chrome-extension
npm install
npm run build
- Go to
chrome://extensions
and toggle on "Developer mode". - Click "Load unpacked" and select
dist
folder created bynpm run build
command.
Start the build watch process with this command:
npm run dev
Whenever you do any code change it will recompile the project:
- If you change popup code - you will see changes instantly
- If you change service worker code - you will need to reload extension in
chrome://extensions
Code within this project follows clean architecture pattern.
.github/workflows/
- CI workflows to testbuild
step andtype-check
the project.assets/
- project assets, eg. media, fontscomponents/
- React.js componentsconstants/
- constant variables/enumsentities/
- objects that encapsulate business logic and represent the core conceptslib/
- utilities/helper functionspopup/
- popup-related filesstore/
- entity methods used within popup/optionstests/
- e2e testsuse-cases/
- entity methods used within service workerbackground.ts
- entry point of service workerglobal.d.ts
- global typings
- Service worker fetches new messages from API every 30 seconds using Google Chrome Alarms
- Service worker stores fetched messages using Google Chrome Storage
- No messages and loading states are handled properly
- Any error that occurs is displayed within the extension for easier troubleshooting
- State management is handled with help of TanStack Query
- UI is styled using TailwindCSS
NOTE: Right now all requests are mocked and have 1000ms delay in
lib/delay.ts
NOTE: Console logs added for easier troubleshooting of requests extension makes
- Handling online/offline with help of
navigator.onLine
or handling fetch errors. - Handling fetch pagination and storing only latest messages in Google Chrome Storage.
- Creating centralized place for handling communication between ServiceWorker <-> Popup
- Reduce Google Chrome Storage data usage by compressing messages