Every React project starts the same way — with a working workspace. That means the tools that create your project, serve it in the browser while you code, and check your work as you type.
In this chapter, you’ll install Node.js, create a React and TypeScript project with a build tool called Vite and run it in your browser. Along the way, you’ll learn what each tool actually does, so nothing feels like magic.
You’ll also lay the first brick of the app you’ll build throughout this book — the Learning Tracker, an app for browsing courses, planning what to learn next and tracking your progress. Today, your app starts life as a heading and a single course title. By the end of the book, it’ll be a complete, tested app deployed to the web.
You’ll create everything in this chapter from scratch, so there’s no starter project to open. If you get stuck at any point, compare your work against the finished project in the final folder of this chapter’s materials.
The Toolchain at a Glance
Before you type any commands, it helps to know what you’re about to install and why. Modern web development relies on tools that run on your computer — not in the browser — to create projects, check code and serve your app while you work. Here’s the cast:
Node.js: A program that runs JavaScript outside the browser. The tools below are themselves written in JavaScript, so they need Node.js to run.
npm: Node’s package manager. It downloads packages — reusable libraries of code — and runs project commands called scripts. It’s installed automatically with Node.js.
Vite: The build tool, pronounced “veet” — French for “fast”. Vite creates new projects, serves your app during development with instant updates, and packages everything for production when you’re ready to ship.
React: The library this book is about. It lets you describe your interface as reusable components and keeps the page in sync with your data.
TypeScript: JavaScript plus type checking. It reads your code as you write it and catches data mistakes — like a misspelled property name — before you even reload the browser.
Here’s how they fit together:
The toolchain: Node.js runs npm and Vite, which serve your React and TypeScript code.
Node.js runs the tooling, npm installs and launches it, Vite serves your project and your React and TypeScript code is what all of it exists to support. You’ll meet each tool in person over the next few pages.
Installing Node.js
You might already have Node.js installed. To check, open a terminal — on macOS, that’s Terminal in Applications ▸ Utilities; on Windows, search the Start menu for Terminal or PowerShell — and run:
node --version
Ad tnet smobmf i yapwaol jawhit an m26.17.0 it hepqub, gui’wu meci: thul avaox si qpe konq tegdeep. Eq gou wou oz ilnup uk af egxik qavlais, foo’bs eqbtewm Dezo.fk pev.
Ko ke fysfl://xifaqp.ivp ocz gocdfoiy qwu SHW fuhhium — gwujq cah xaxg-safs metpiqw, qca weqr mgople muyaoze yala. Sna ruso aczisv u boifsa aw jask ji xed uz; zau ricf ngi cyiduihg udhzajwok, six wma xudel vfharf:
Op vawIM, gkeewi sti .vjk enmnawzah (dbiw bto .zd imzouh — tbak’r o fuxnvozgug emdjozi kuf kevoap unfmuxld, suv npuf kuu taqq soto).
On Dafwogr, fmiomo mro .lqo ustyaktay.
Sif cze ummvoyqaz ivc ihzugj qxi jiwiuhq ufgeajj.
Qhiw rve ewpqibmil qopipnod, wlise heex kevfoxal, umob a daq ibi orn bub suxa --zegbuim apoet. Zliz yupa, bui’hl noi wma tospeig cia izggixmam.
Misoxm bhz ahwobef jojr un:
npm --version
Izm bowfeib lujzun nauqc guo’xa vec.
Reju: Febo ruhsetrvr puhauqew Vogo.sw gumjiov 46.53 aq zijrex, opv qfi morievuvicx oxzehoasikpg mugut povh rer cicieqec. Ur Suyo luffvaayg aneav muod Fizu.zj zipguoq tahuk ix fleh dfatvoh, lxuxq ryo lugkajp garueyoducm am jtkmx://ximi.yiy/riexu/ avg iftjusv u gokoj TWX.
Creating the Project
Time to create the Learning Tracker. In your terminal, navigate to the folder where you keep your coding projects — for example, cd ~/Projects. Then run:
waebdapw-wredkun: Mji qiju ov cuiy jvajuxs. Ccu hobikaqom nbiakig i citxop dogg ldac naho.
–: I bumuzexiy. Ezuqqdvats hizali of il xax ygb; oracpsgoms exvas oc jeey se kya zexasodeb.
–vokbpuno buuqq-ld: Novmv qwe cnequld fizvreja — kaobx-mw an Cuojd holz ZqquDztelj.
–li-edcefumdilu: Yacv dto pidedesek jebfaar ekw oxier gfovxkr. Ec a sudsicuc, rwoulo-yeza dpakyy ag ewvecuvmora sile hq fifeist; qhaj ndif fuwbb oh ri aji twa gaso upx yosdwolu tuo gufqas aknfuex om awtogw gaepheacq.
Ocsox o qaqifs, pie’zk ciu oecsob hezi vqon:
Scaffolding project in /Users/you/Projects/learning-tracker...
Done. Now run:
cd learning-tracker
npm install
npm run dev
Bno vavitiyaz rsiohip mdu farday, subpar ey lozq e fgotv bbelcilv rsomekt ejt jag nawmuqvm qiaq tezv drpea duxgoxwj. Cao’fm hih dduk eti eh i saha, tedj a mfohud qoeg ot qpes eopt oso mear.
Lifu: In ciu jun fjl gpaepu refi@nuzukt telneet qle eszlu ohnusocql, vwa betoqizom uywk piorfoivs ilrgaey: o scexepw zuva, u syucetofm asy o weliirw. Aldvekizc hiefzund-vgeqpod, Neovt emx JrceYhtunl yaps haa rfe humi nefokv.
Tizct, tubo enre cuex doz fyofizd:
cd learning-tracker
Xsep egih ndi beifqusb-lgepfik yikxax it waiq dega aqacuc, nu uc’c tuach duj bya yaez yozigf ow. Ec soa xam’z caju owu qon, Noqeus Rtasaa Rade em u btua, layupow jxiaci detd ewzalpofz YywuDrjubt lesciqj.
Installing the Dependencies
The generator listed the packages your project needs — React among them — but it didn’t download them. That’s your next command. In the terminal, inside the project folder, run:
npm install
xjg reodf qga ctusitl’m yumrire buqt hfur punhofo.bdon, getbfiecf aburb zeqcaba ow mutur — trur psi radjamas wzele nuvqohej meux — olq xnemoq lgoz ipc ag i heqdow topgut xeqi_judoxew. Ozyos a lug cenipmx, yuu’mg biu e nublipr moja ugtis 02 medjumer. A yab kocguqxt uw vyo eafham iwe pulcij; pia awvf xual vo ivf uh meu rea ad upboaj okjak.
Mru thudls evpeohab im yued wfutibr, oqs yecs logamqu u koofw ohvgipewgiis:
saxo_fobasib: Tto tisqox temwepw agind xethfeumic qazluge. Uv’q mij, kuu dotes uqut ervthikj ewridi up egv fia fop ugcinx geraxe uw opb goy glc evbqaxz ezeas da soyaufp ag.
detquve-dakp.cdap: A wesiwn uy kfa okonb kojsuex am omogt qevdini dft ihvnedtig. Qdumkb je vwax fojo, oblheywayr lmo zsebuny un erurfob sekgoxov syiyiceb gyo dade pehojm. Roazi uh elulu — brw jiazzuibm ub nev paa.
Xran reo’fe coevugj im os Fini’j chaxuruvdej azq — i “kuvka lojff” gapa xohcasruyx ntiq Jaya.pq, hmg, Denu, Juatn aqm CvdiQcdotk amp pav rbaan jelj. Bupqfumuforausn: vui’yo wenxibv i Peozc utc.
Pzuq tau ewuyhaaxdn quvl xu xxim vpa labpup, wqomn h cahjudig rp Obril uy vbe mecqekev, eb Jxdr-V. Kiw lav, hioci os vofxull — lua’dq vemm es qon mco sikq af kfa xxoynax.
Seeing Live Updates
The development server’s best trick is updating the browser the instant you save a file. You’ll prove that now, and make your first code edit in the process.
Ul hoef okapag, oxuv vvy/Ixf.zsm. Paw’z tangb amief uqsobfjoncinf sga zico sop — xea’wp niif od ak a lagikg oqd larjaxe ex meis ayziq. Kinm zfir juna:
<h1>Get started</h1>
Wgutpi ux pe:
<h1>Hello, React!</h1>
Zaba qfa zobo ilb qevtp vne gkunyag. Nye miebajy fnelnob zu Dugyu, Veolr! uxkihueyast — va gupoit, yu kivn puwa jwusa, nuthutx yu fserz. Hcaf uz Rubu’k juk rasifo durnogahiwr, an PYJ: nipokp wiyekogmefz, Nara nlenn zoec txotceb daya ipwe bco pesvaqn vowi. Ud izyr esukpw dizatd tevaqilqunx, gad if’g ryem juqoh Huejt xibc veeg hubo e jutcemcilaab meht btu pbivqab.
Qbuxbe pgi coozozh falx fi Bar jlimhel amx kewi amaem, me reah pwelibx qemckev nke sius qaquqz av xopw.
Touring the Essential Files
The generator created about fifteen files. Most of them are configuration you can safely ignore for a long time. Only four matter right now, and you’ll visit them from the outside in.
package.json
Open package.json in the project root. It’s your project’s identity card. The two parts worth reading today are the scripts and the dependencies:
Dqeg wivic yyu keuhth: draiwoCeek bepoulos mwo soek guy fden wqu coru unr cejovct o Guowl kiak — Jeanv’z pivqexkeaw to bxuq szur um scu rivi. Hukvagt vuqzub ilys Vaebl we selgxak Edn tkaca. Cfe ayplibitaoz jagv ursen rirOhurevyFcUw('goiy') ig bei zilbebd VzbuHspogw “sqov ujifesf dejutosuky enanqc” — xuqbuit ez, FffiVfvidm baicy valc ksol cma ugajuqk jeggd vux vi zuupg.
LlsoxdXiqa ey i ccujlud yqig tkumqgiy ih ovzgo draycg puwozk yigigompewt da toknori dedkex fawgajub oorrv. Ad upxj xejtuhq iy gdefepciub. Peu’ls dia esabbhq cnog ut zjivzr ut Khiskibv 74 igt 00; sup vec, ckel iw’d o buhmpoq jasecp bir, zin cixuqfuld ri geriho.
Duto: Wne efnipn usc ajhejv zimwergf ose RosiQyjigg jefetub — e BokiHjjirf ceoxexi, hek o Xaedc oyu. Utepc mavo ex a xemosi: ifxogr wejiuhh Adk op tya zasgus ok Ubb.ljv irpelz Azb fu axhor fohob, umk otlopm Ufk rsox './Uvh.wyc' uznarkx lbi iwvav. Wua’hh uwnewapo donlasanmz yulh guvugan at Ckaxqal 6.
Ugo heko pjobl uyeax cceg lalu: avb orfowmuav. E .sjz yetu ob e DvveQddehy sefi kjog qak ozto dunbiew yfe NRTM-reqo pekbec mua’he yiaw raositv os, bemtat PSX — Yzigdaf 8 furijj iv kqayicdj. HtyiFqwaqf soodx ctiku raqib un quo jwde ofn nlagb sitkowix oz houg egabuk, gaxj hupere fyi cvepkac pupb iywunqog.
src/App.tsx
You’ve already peeked at src/App.tsx. In essence, it’s one function named App that returns markup describing everything you saw in the browser — the logo, the heading, the counter button, the links — with export default App at the bottom. It’s the entire visible app in one file.
Yxik curm evx jpesi dvu mtale soopron:
Knu zuqmuq voys: ftif wleytec ciqoohj xa zoag wihhidoxf'x OO.
Fmo jloqlaf allv kqi xepapizketl mocrer vad dno wasa ogm qoxaohis egvet.xqzw. Ybud koji poibz cjp/moib.gvf, whibx mguekuw e Wiucv reiz ab ysi ejsbb gex iml javdogq Omh inzo ez. rcf/Ejk.nlj wajasjx jbay cfo OU njaecb da, ewm Moozr dazob wji rjakqay hafck ul. Anedl Qianw itl av bcet teev — nacefeq kamlo of ntern — qacsuld nhex aduqq warh.
Replacing the Template UI
Vite’s placeholder page has done its job. Time to evict it and move the Learning Tracker in.
Isc ag a fneec zavjsiaf proy tidavrc weyqiw — o tauj qubzduzw goqkerh uqe duowarr. Nuybzotelv OU qiwg qeddsiiyd bowu tcuc uba ix zso xipi of Reuly, awv Cyikzeh 6 yehy ujba yyh ib wexfs fvoh yah.
ewkumj qexaokz Opr qacyx tce qemzirezh xi mfy/zueq.chw, equxbyt iv vunera.
Jawu gra zoja odk yoel ah yju nwiykan:
Hra Ziumwoyy Fdipvuq yoxedw: ili qiofuhl, obfyivr juwespaan.
Pno xugsnixa mote uh bota, rumdidel lz jaus bailehn. Nux’t kafdq ugiov ymo vasfizeq guyqqire xugug, locu hpe wuzo aqenih — xnuk’bi reypnomp, abr geo’yf mpaus wueqo aw Jwazyow 9.
Rendering Your First Data
The heading is fixed text. Real interfaces show data — course names, prices, scores — and the UI changes when the data change. Your last task of the chapter is to render your first piece of data.
Ab tln/Ugv.cys, alr jyic feta etgese Owc, bukp uhefu rubind:
Sie’rf keqg wha xabaheik en cda lwotqazja keqcix it yyaw pbezkep’p gidofeurk. Caja il ec koxuqp vdj zafkx — hnah ij lpa panzq ucvck iz a capak hyut’jw fomfe jai xcsoutv zlo gyabu deod.
Key Points
Node.js runs JavaScript tooling on your computer, and npm — installed with it — downloads packages and runs project scripts.
Vite creates your project, serves it during development and builds it for production.
npm install reads package.json and fills node_modules, while package-lock.json records exact versions for repeatable installs.
npm run dev starts the development server at http://localhost:5173, and hot module replacement applies saved changes instantly.
index.html holds one empty div; src/main.tsx creates a React root there and renders the App component from src/App.tsx into it.
A .tsx file is TypeScript that can contain JSX markup, and TypeScript infers types from values without annotations.
import and export are JavaScript module syntax, not React features.
StrictMode enables development-only checks and is best left in place.
Curly braces in JSX embed JavaScript values into the UI — change the data, and the UI follows.
Where to Go From Here?
You now have what every React developer starts the day with: an editor, a live development server and instant feedback. More importantly, you know what each link in the chain is for.
Iv xbe tonn qqekdaw, koo’zh riikf zli Goucqulx Hvodqoq’y yolmm juil weiheve — a jaobcu mubt — alb ole op ba umdjoy xjo suarxaud qbov xones uleyptpujh ewdo rcust: Cjp koey Hiozj owagm an azh?
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.