Full Tutorial | Building a Chrome Extension in Typescript and Vite

  Рет қаралды 86,114

Train To Code

Train To Code

Күн бұрын

Пікірлер: 165
@playagain4397
@playagain4397 Жыл бұрын
I had to play around few videos before I land on this, and it's bang on; explained so nicely with easy steps. Great tutorial! Thanks.
@justin9494
@justin9494 Жыл бұрын
this is so well produced. You deserve more subs! Thanks man
@traintocode
@traintocode Жыл бұрын
Thanks - that means a lot :)
@Immigrantlovesamerica
@Immigrantlovesamerica 11 ай бұрын
How is it well produced?? The video wouldve been great if the audio didnt cut out, or if the video wasnt cut in half. He also didnt upload the vite app to github like he said he would in the video.
@sujansinhthakor2314
@sujansinhthakor2314 4 ай бұрын
this is one of the well documented video on extensions,
@cryptosauce_
@cryptosauce_ Күн бұрын
excellent introduction to really settle the viewer in nicely
@baljinderbenipal5804
@baljinderbenipal5804 Жыл бұрын
Phenomenal tutorial James! This video has all the relevant information required for development and the iterative approach is extremely useful. The end product is awesome!
@traintocode
@traintocode Жыл бұрын
Awesome, thank you!
@PaDSt3r
@PaDSt3r Жыл бұрын
Wow life saver! I didn't realize I could pass state into the dom and always thought I was limited to using state in the popup
@havfdeco
@havfdeco Ай бұрын
FINALLLY SOMEONE WHO EXPLAINS IT :D
@semireolatunde-salawu758
@semireolatunde-salawu758 12 күн бұрын
Really easy to follow! I'm using plain javascript to build my extension but I really benefited from this!
@davidc.2525
@davidc.2525 7 ай бұрын
Not even done yet but this is for sure the best chrome extension tutorial on KZbin!
@traintocode
@traintocode 6 ай бұрын
Thanks!
@girldocode8408
@girldocode8408 24 күн бұрын
how cool ! thanks, this was very new and helpful for me
@AutomobiliBeast
@AutomobiliBeast Жыл бұрын
Dude dont stop the prod. You deserve a lot more subs than this. This channel is underrated
@traintocode
@traintocode 11 ай бұрын
hahaha thanks! My channel is growing steadily but I just like making videos
@seriouslee4119
@seriouslee4119 Ай бұрын
Sweet tutorial, just what I needed. Thanks guy!
@EpicKeyz
@EpicKeyz Жыл бұрын
Hey, thanks for the tutorials. I'm just starting to learn how to code my own Chrome extensions and I really enjoyed your detailed step-by-step guide! Also, I wonder how do you type so fast? Or did you just record a coding video and then recorded your explanations?
@traintocode
@traintocode Жыл бұрын
Thanks! And yes I recorded the typing separately. Everything is a lie
@KryptechOfficial
@KryptechOfficial Жыл бұрын
I was wondering the same thing, until I some him "typing" with his hands off the keyboard 😂 It's a good idea!
@tbbbasjwqkkksjj
@tbbbasjwqkkksjj Ай бұрын
Thanks! your tutorial makes beginner inspired to build more extension. Subs!
@MoonLee-w3k
@MoonLee-w3k Ай бұрын
Nice explanation of the basic concept of Chrome extension
@matt-pierce
@matt-pierce Ай бұрын
Amazing video. Learned so much so quick. You are clearly very knowledgable about this topic :)
@ronaldsupenieks803
@ronaldsupenieks803 8 ай бұрын
Nice video man. What's missing in this is a hot module reload set up - something I'm trying to figure out. this way you don't need to keep running the build command but have your changes appear live in the extension
@5minutes106
@5minutes106 3 ай бұрын
Thank you. Everything was explained clearly. Just the video i was looking for.
@bobsmithy3103
@bobsmithy3103 7 ай бұрын
goated. Best typescript extension tutorial
@traintocode
@traintocode 6 ай бұрын
Haha thanks
@0jaxay0
@0jaxay0 2 күн бұрын
really nice tutorial, thanks!
@ThomasChester-e7g
@ThomasChester-e7g 2 ай бұрын
PSA for anyone whose button doesn't work when following this: it might be because of an update to Chrome, but I had to add an argument to the tabs query: "let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });"
@traintocode
@traintocode 2 ай бұрын
Thanks! I'm trying to work out a way to host the source code on my site so I can add a link card to the video
@robj3d3
@robj3d3 7 ай бұрын
Mate, you are absolutely brilliant. Incredibly well taught and presented. Thank you so much for this!
@markuscwatson
@markuscwatson Ай бұрын
absolutely beautiful tutorial mate. u have a new sub here
@mikkun_
@mikkun_ 9 ай бұрын
Man this summarizes everything I've learned so far in creating chrome extensions. You earned a sub from me!
@traintocode
@traintocode 8 ай бұрын
Thanks so much!!
@vinod.sharma
@vinod.sharma 4 ай бұрын
I loved it. It is easy to follow and gave me basic information to get started. Thank you very much for posting this video.
@alexdin1565
@alexdin1565 6 ай бұрын
Nice video man! Short and to the point.
@cirExUAB
@cirExUAB Жыл бұрын
Thanks, you really help me to understand how work with "two scopes" (extension and web). keep going!!!...
@traintocode
@traintocode Жыл бұрын
Thanks, will do!
@pavelsavelev2560
@pavelsavelev2560 11 ай бұрын
great video man , just wanted to say thank you.
@traintocode
@traintocode 11 ай бұрын
thanks!
@oletrn
@oletrn Ай бұрын
amazing tutorial, thank you so much!
@kumarchandresh0
@kumarchandresh0 Жыл бұрын
Dude is managing two spellings of color in one file. Respect 🫡
@traintocode
@traintocode Жыл бұрын
Unless the spec makes me spell it incorrectly I will go with "colour" whenever possible ;)
@MincongHuang
@MincongHuang Жыл бұрын
Thanks for this great tutorial, it helped me initialize the plugin quickly and understand the structure of a plugin.
@traintocode
@traintocode 11 ай бұрын
You're very welcome!
@姬霓太美-w1z
@姬霓太美-w1z Жыл бұрын
Thank you so much, it's an amazing tutorial for Chrome extension!!!
@virtual5819
@virtual5819 3 ай бұрын
exactly what I was looking for!!
@fabianmerchan
@fabianmerchan 7 ай бұрын
Great tutorial, keep it up bro!
@traintocode
@traintocode 6 ай бұрын
Thanks, will do!
@leonardoalmeida7746
@leonardoalmeida7746 5 ай бұрын
Very helpful with clear instructions and very didactic. Thanks
@omarelouafi
@omarelouafi Жыл бұрын
Thanks for this quick and concise tutorial !
@mightyboateng
@mightyboateng 6 ай бұрын
That was valuable. Thanks for creating such a tutorial.
@ipranay
@ipranay Жыл бұрын
Very cool! Thanks for the tut!
@traintocode
@traintocode Жыл бұрын
No problem!
@mrlectus
@mrlectus 10 ай бұрын
Any solution to the "I have to build the file all the time"
@otisrancko
@otisrancko 2 ай бұрын
this is now 10x content....Thanks
@super-social-saltyfish
@super-social-saltyfish 5 ай бұрын
this tutorial is good for who looking just start want to build a extension
@Ryguy12543
@Ryguy12543 10 ай бұрын
Awesome video. Thank you :) Very clear.
@maninalift
@maninalift Жыл бұрын
When you get to using Vite, you switch to having javascript files that are referenced from an index.html file. This suits what Vite expects, and allows Vite to use the index.html as the entry point, but for most chrome extensions, you will want to have possibly multiple javascript entry points that are referenced from your manifest.json and not from an html file. Is there a way to do this? I'm tempted to skip Vite and just use tsc directly to build. EDIT: I gave up too easily looking for an answer. It looks like it's actually quite easy. I haven't tested this yet, but something like: javascript // vite.config.js import { defineConfig } from 'vite'; export default defineConfig({ build: { rollupOptions: { input: { page: 'src/page.ts', options: 'src/options.ts', worker: 'src/worker.ts', // Add more entry points as needed }, }, }, });
@nafiulawal1443
@nafiulawal1443 16 күн бұрын
Why not have one entry point and use some logic to execute individual entry points?
@MuhammadHamid-r6o
@MuhammadHamid-r6o Жыл бұрын
unbeliever you are doing such great job
@kunalukey5870
@kunalukey5870 Жыл бұрын
Nicely explained! subscribed ❤
@traintocode
@traintocode 11 ай бұрын
thanks!
@kumarutsav1123
@kumarutsav1123 3 ай бұрын
Bro so good, I immediately subscribed
@tommmosadeq9843
@tommmosadeq9843 Ай бұрын
A great tutorial, thanks a lot
@kooday
@kooday 6 ай бұрын
Can you please explain how to use the service worker with vite build
@DelwarAhmedHabib
@DelwarAhmedHabib Жыл бұрын
Just wow!. I was exploaring if it is possible to create extention with frameworks like react or svelte and found this. Thnks a lot.
@traintocode
@traintocode 11 ай бұрын
no worries thanks for commenting
@hurdurstudy295
@hurdurstudy295 9 ай бұрын
this tutorial is amazing
@traintocode
@traintocode 8 ай бұрын
Thanks!!
@dmitriyvainila4227
@dmitriyvainila4227 9 ай бұрын
Wonderful video! Thank you, mate. Subscribed for more :)
@traintocode
@traintocode 8 ай бұрын
Glad it was helpful!
@jeswer9
@jeswer9 Жыл бұрын
Deserves way more views!
@minaamir3056
@minaamir3056 Жыл бұрын
okay, So where i should put my background file then??
@mahmoudaboueleneen
@mahmoudaboueleneen 11 ай бұрын
Amazing video, so useful
@traintocode
@traintocode 11 ай бұрын
Glad it was helpful!
@moulcode
@moulcode 10 ай бұрын
Great video hope we see advanced videos like for example auth with supabase using the extension etc
@btechstuff
@btechstuff Жыл бұрын
very helpful and clear
@traintocode
@traintocode Жыл бұрын
thanks!
@fandhipray
@fandhipray 3 ай бұрын
great tutorial sir thnakyou ☺
@ericborder5996
@ericborder5996 Жыл бұрын
I still feel some gap between using chrome extensions from the scratch and with vite installation, but anyway this video helped me get started, thanks!
@mohammadrezahosseini8435
@mohammadrezahosseini8435 3 ай бұрын
Great work of you
@AdityaG.
@AdityaG. Жыл бұрын
Thank you sir, this is the exact solution for my problem...😄
@olumideoni8101
@olumideoni8101 Жыл бұрын
thank you so much, Great video
@traintocode
@traintocode Жыл бұрын
Glad it was helpful!
@ritavdas7570
@ritavdas7570 Жыл бұрын
Great tutorial , but one part I didn't understand is you told me that we need the *Content Script* to actually change the content of the page we are interacting with. But here you directly modified that in the same file where we were running that popup. One more thing why did you clear the service worker file ?
@idle.observer
@idle.observer 11 ай бұрын
I have spent over 5 hours just loading unpacked extension files. I am using Linux (PopOS) finally with help I found the issue. Because of portal bugs, if your source code is under home, it won't see it. Even if you click the button and select the directory, nothing changes. Move your source code under another directory like Documents, instead of Home. If the button still the button still does not work, just drag the directory (folder) and drop it to the extensions page. It should work.
@goldenboy3627
@goldenboy3627 11 ай бұрын
if you can make a tutorial of automating clicking element selectors while the user is opening another tab while its performing the actions in the background with no interruptions would be very helpful i would even subscribe.
@traintocode
@traintocode 11 ай бұрын
You sir have a high price for clicking subscribe but it's a great idea thanks!
@jaybeatz8084
@jaybeatz8084 11 ай бұрын
it works bro thanks 😀
@traintocode
@traintocode 11 ай бұрын
No problem
@learning_trespasser
@learning_trespasser 5 ай бұрын
nice explanation
@vedbhanushali608
@vedbhanushali608 8 ай бұрын
sir very helpful tutorial, thank you for great explanation, I have still one query how to do background service and content service to run on it ?
@rfgonzalezweb
@rfgonzalezweb Жыл бұрын
hi, great tutorial, I have a question, let's say I want to use the chrome.storage.sync.get API inside a useEffect in my App.jsx file so I keep synced my service-worker and my popup, when I run npm run dev, react does not have access to the chrome API, how can I access it to keep emulating my chrome extension in dev like it were a standalone react app?
@eliasbenjamin4228
@eliasbenjamin4228 11 ай бұрын
I'm wondering the same thing!
@ivodelev9794
@ivodelev9794 10 ай бұрын
there is beta vite plugin
@TheDemoded
@TheDemoded Жыл бұрын
please share the whole project. due to screen capturing issues it's unclear in some parts
@traintocode
@traintocode Жыл бұрын
Absolutely! Here is it on GitHub github.com/traintocode/sample-projects/tree/main/simple-chrome-extension
@oleholgerson3416
@oleholgerson3416 Жыл бұрын
@@traintocodeThe typescript + vite part seems to be missing.
@markh9646
@markh9646 Жыл бұрын
Hey @@traintocode Could you send a link to the code that includes the ts + vite section? Seems a lot of the code is off screen it's difficult to follow. Thanks!
@tfdesign4072
@tfdesign4072 6 ай бұрын
perfect tutorial! can you make a chrome extension that handles auth as well? i.e. to check what functionality a user can have access to?
@ArmanJindal-ls8yo
@ArmanJindal-ls8yo 8 ай бұрын
Awesome video! Thanks so much. Quick q: how would you pass state from the page context to the popup context? I love that we can easily pass from popup to page via the args function, but what way would you recommend to go from page -> popup. I want to have my popup react to the current page the user is on! Thanks :)
@KeshavD-ys7el
@KeshavD-ys7el 6 ай бұрын
How to work with service_worker using vite
@donnieyang7453
@donnieyang7453 10 ай бұрын
Great! nice tutorial
@wellshubtube
@wellshubtube Жыл бұрын
Thank you for this video but can you explain how I can pass a function state to the DOm?
@LearnCodeFromForeigner
@LearnCodeFromForeigner 5 ай бұрын
❤❤❤ but i have a little bit confuse about popup context and content script in the section use vite. Why change theme in onClick impact to the whole page
@edoardododoguzzi
@edoardododoguzzi 4 ай бұрын
Excellent video but in some point missing audio
@eliasbenjamin4228
@eliasbenjamin4228 8 ай бұрын
If you wanted to add a service-worker to the vite application, would it be in the public or src folder, and how would the manifest point to it? Thanks!
@traintocode
@traintocode 8 ай бұрын
This article might help but I've not done it so can't speak from experience dev.to/reeshee/how-to-bundle-your-custom-service-worker-in-vite-without-using-pwa-4nk
@rahulxfd
@rahulxfd 4 ай бұрын
which cli(terminal) are you using ?
@christianbensoncapon
@christianbensoncapon Жыл бұрын
Awesome!!
@traintocode
@traintocode Жыл бұрын
Thanks!
@longqi-b8s
@longqi-b8s 6 ай бұрын
Thank you for your excellent work. My VSCode doesn't suggest any correct methods when typing "chrome." Please help.
@Morimove
@Morimove 7 ай бұрын
nice tutorila but i need to build everytime. do you have any solution for it?
@rodrigoserrasqueiro
@rodrigoserrasqueiro 4 ай бұрын
I have a question. Would using React in an extension somehow affect production performance compared to pure HTML and JS?
@CaleyHamiltonProjects
@CaleyHamiltonProjects 11 ай бұрын
Can you do a tutorial for a side panel chrome extension
@traintocode
@traintocode 11 ай бұрын
What do you mean by "side panel"? Like some UI that gets injected into the actual page or the popup when you click the extension?
@CaleyHamiltonProjects
@CaleyHamiltonProjects 11 ай бұрын
@@traintocode No it's a newer chrome api which persists across page navigation and page changes. I can't post links because the last comment I did that got deleted Just look up "side panel chrome api" to see the api docs and search the same on youtube to see how it looks
@CaleyHamiltonProjects
@CaleyHamiltonProjects 11 ай бұрын
@@traintocode This is my 3rd time trying to reply to this post. Idky it keeps getting deleted. The side panel chrome extension is a newer api which persists across page reloads, navigation, and tab changes. I would post a link but I don't want the reply to get deleted a 3rd time. Just look it up on google to see the api docs and look on youtube to see the UI in action.
@CaleyHamiltonProjects
@CaleyHamiltonProjects 11 ай бұрын
@@traintocode This is my 4th time trying to reply to this post. Idky it keeps getting deleted. The side panel chrome extension is a newer api which persists across page reloads, navigation, and tab changes. I would post a link but I don't want the reply to get deleted a 4th time. Just look it up on google to see the api docs and look on youtube to see the UI in action.
@CaleyHamiltonProjects
@CaleyHamiltonProjects 11 ай бұрын
@@traintocode This is my 4th time trying to reply to this post. Idky it keeps getting deleted. The side panel chrome extension is a newer api which persists across page reloads, navigation, and tab changes. I would post a link but I don't want the reply to get deleted a 4th time. Just look it up on google to see the api docs and look on youtube to see the UI in action.
@LucianoMendes
@LucianoMendes 11 ай бұрын
Hi man, wanderful video, I love it. Can you help me, please? I have a extension built with Vanilla JavaScript and it rund when the page load, I followed your video but I can't do it run when the page load, only when clicked. How can I do that?
@justin9494
@justin9494 Жыл бұрын
no hot reload?
@traintocode
@traintocode Жыл бұрын
There are libraries that claim to make this possible but I just don't have experience using them github.com/xpl/crx-hotreload
@AndreiDamian
@AndreiDamian Жыл бұрын
Nice introduction! Saving, running npm build, reloading the extension, reloading the page (maybe this is somewhat optional) seems to be very tedious. It would be nice to have at least some of these steps automated. Also showing some more errors, e.g. in background scripts and how to debug them would be useful for beginners.
@chrisder1814
@chrisder1814 6 ай бұрын
hello I would like to develop a chrome extension but I don't know if my idea is good and could you tell me what you think about it
@maanas_sehgal
@maanas_sehgal 4 ай бұрын
Someone please help me I want to integrate monaco wirh my extension but its showing loading and is not coming. My whole extension depends on it😓
@alizaidbaber1905
@alizaidbaber1905 5 ай бұрын
i am facing an error of undefine the chrome keyword even after install the package in my react app.
@jianjunxiao5779
@jianjunxiao5779 Жыл бұрын
how to write a content.ts and then produce a content.js in dist
@traintocode
@traintocode 11 ай бұрын
Run "tsc" to compile the .ts to .js. Or use a build tool that does this as part of the build process, such as Vite
@keshav_dhiman
@keshav_dhiman 8 ай бұрын
howto implement background scripts?
@symbi21
@symbi21 11 ай бұрын
so where can i found the source code of the vite? onChange code is half in the video
@traintocode
@traintocode 11 ай бұрын
Hi! source code is here: github.com/traintocode/sample-projects/tree/main/simple-chrome-extension
@piotrs448
@piotrs448 10 ай бұрын
And how to read page document in extension?
@juangabriel2559
@juangabriel2559 4 ай бұрын
Goated!
@tubemyren3038
@tubemyren3038 6 ай бұрын
I cant find the source code for the React/Typescript example.... you are missing some codelines in the video, but cant find the source code!
@EvansRutto-kd8fw
@EvansRutto-kd8fw Жыл бұрын
awesome ..👏
@PokeFangOfficial
@PokeFangOfficial 4 ай бұрын
So frustrating, I tried to launch my extension but keep getting auth2 errors and each time I load a new version in developer mode it creates a new ID. Any ideas?
@Abcdef-hq3vf
@Abcdef-hq3vf 7 ай бұрын
I want to know how to make an extention which could be interacted by a website. In other words how to manage content.js and background.js console.log('Content script loaded'); const script = document.createElement('script'); script.src = chrome.runtime.getURL('inject.js'); (document.head || document.documentElement).appendChild(script); script.onload = () => { console.log('Inject script loaded'); script.remove(); }; window.addEventListener('message', function(event) { if (event.source !== window) return; if (event.data.direction && event.data.direction === 'from-page-script') { chrome.runtime.sendMessage({ type: 'CUSTOM_WALLET_REQUEST', payload: event.data.message }, (response) => { window.postMessage({ direction: 'from-content-script', message: response }, '*'); }); } }); THis is an example code
@pavelgrishin
@pavelgrishin Жыл бұрын
9:51 this leads to anonymous function error
@traintocode
@traintocode 11 ай бұрын
The full source code is here on Git I may have copied something wrong in the video github.com/traintocode/sample-projects/tree/main/simple-chrome-extension
@idle.observer
@idle.observer 11 ай бұрын
could you fix? I can help
@rahulgupta373
@rahulgupta373 9 ай бұрын
18:55 why i cant listen anything 😕??
@davidc.2525
@davidc.2525 7 ай бұрын
I was confused too. Thought it was my airpods haha
@nonamenothing2000
@nonamenothing2000 3 ай бұрын
if you want to do a tutorial video, please make sure the video show all of the code...
How I Built It: $20K/Month Chrome Extension
13:13
Starter Story
Рет қаралды 220 М.
Why Does Everyone Underestimate Chrome Extensions?
1:17:42
Steph France
Рет қаралды 23 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 324 М.
Build a Chrome Extension With React & Webpack
17:44
Codify Tools
Рет қаралды 45 М.
Create Google Chrome Extension In Minutes With AI
12:40
Monika AI
Рет қаралды 4 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 969 М.
12 VS Code Extensions to INCREASE Productivity 2024
27:13
Devression
Рет қаралды 885 М.
I Built an AI Chrome Extension in 30 Minutes
18:19
Piyush Garg
Рет қаралды 48 М.
Create a Chrome Extension with TypeScript
10:33
WittCode
Рет қаралды 4,9 М.