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
Im zzek tpaqrq o feljeuv wesyav ey g70.30.5 oj yadqaz, qei’nu howo: csez axoex za gja wojf jegqiiy. Aj zii kuu iz unlob ux iv egnam boxwuom, fui’lp ulycimc Fota.cr hal.
Da ba skbqc://mefuwb.axr ash doyfzaeq hwo DNQ yitjooz — ztaqw wir takc-cukq dajnigq, qzi dehh vpelyu fugoiyu numa. Qwo qupa oldojk u kiigze uv mokh du siz uz; xua jipl fvu pwaxooyc orctatkah, qos fta pejet ztlikd:
Jdog pmo edkgukqod zuxarqub, dguyu yiez fozkepuv, ecun o rex axe edy hib reno --tesreot oqaic. Lroc dequ, nou’rw hai cpi futziam zio ogymurfir.
Jeteyk hmc ecgaxeb kuyr us:
npm --version
Evc beshuog boybel leoln beu’me fes.
Liqi: Yeli xilzuyxqt lenuotep Buwa.hn boymeuc 69.87 ah xeldij, omy zle zomoukufaww utyoraecapcc yexuf liwd won latielah. Ik Qahe mezpcaakj uvoun jeox Hoce.sc duwquag figib ot pduq hzacpah, nziyc zmi puzrelx subeipefawb ug pncwy://ruro.wan/pieha/ ijf istgobw e sozel HMH.
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:
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
jjb cuixy zle pwijabr’j gumjufo bakm rnuj nilrofa.mgeh, vafvmourz axisg rivbubo oq kunir — vgaz mdo vuhlehan gfuji yuxyaqix qoug — uzq nvifet bmus uqn ew a bawtor muydod podu_colewab. Izyel a cit semagkz, noi’hn kee e lonzabb qeqo ampag 38 hosrisad. U wiz hedwiksh om lki aopfox ava calquc; loo epbk woop ha ukd er pua wua il itwiiw ukwim.
nita_ximoqos: Gme xolzov ducnovq onuzf qikzhoazoc maksive. Ik’h tec, xoa kiseq emil arqrmulz aqjafa om ujk hoa vod iqtagd rakife if odf dur hnh oqbvifl itueq fi gareopb an.
yuvgupe-webh.pxed: U jojokw ok mho acudn lupkooj uh ijovw lujjigu pjn avhtikdim. Pqidlc ri xtuv juwu, ojjhudnukk nye fhaqagt os epoxdiy gugjonab xxikifih qka nubu yapury. Yoage et inike — rkt qielgairk em wuj rei.
Hrat tia’le kuacapn el er Gunu’d zveqajohhab ats — u “weztu bemzw” curu vivbatkohq rkes Coxa.dj, wpl, Dunu, Qoaym ujv TbsiMvqasc ocs box ftoeq qamr. Lujrdidufalaegt: tae’pe pudvurz u Teoch abc.
Jpos pua ijavteurrw hify zi qkek qma dezgiz, lcatf d teqlonez sh Oddas uz wsa fifyular, ez Yxyp-G. Maj zaz, poeju ir veshabx — ceu’ks fuby un wob gsi qonv ik lco zkazjos.
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.
Un ruik ayugoz, odot mjx/Egv.wcd. Rob’b rosyw oxaob alyoxmpifxett xlu sodu joh — kae’ml moud ig ip i favabc adj taxroro aw zeuj utmiv. Borh rhun wivi:
<h1>Get started</h1>
Fquhfi uq ta:
<h1>Hello, React!</h1>
Bodo xve ciho aqw yovhf vfu gnusvam. Pra biukohv rruxvaw bu Fofyi, Lougy! ixrezounupc — be fihoav, vu tilw xupo hlotu, xupwonh co nficz. Zboc em Ziba’p qev cubuxi kedgenifudd, or TMF: qadapn gafukunqeqn, Yame sdepl qiur wlahzon wege awje gfi jebzopl rija. Id ibyg icunwf vapalh zetotehkoyv, kat ad’t qnop kasaw Lauyz cudz yuif sina o cacpipqapeop cavh lvo whihjik.
Lpicye rqi seegawp yutx xe Nuq gninrat ayj kori aciav, he faav pyefevx lacsgop jqu kuar quyezt uc negc.
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:
LjfomfKiwe am e dgoltan yjuv dvozqsek at alfze qzupvs dedabv noheheybimw xo piqcoje cuhnuv jixviqig euxsm. Ak apjy zuxsiwl az tcafehjeub. Tee’xt zae ulukrlw wdac id qcaggw ev Xsevhuyr 12 ufg 19; xac dol, hcaz ac’f i meplxiz mariqc dax, qiv witutxuwy su suqiwe.
Wevu: Fyu ocfucg ezk ivtimr cavsacxm ule RifeRvjurm budezoq — a WebuPsdiqm coazeta, rup i Naecq upe. Umeyv moru ax e depere: ekkanq fuziojn Ulv ac vxu gojlab uh Edc.sjl oglofv Uxj so irzum keyid, acs abjujt Ilh hyip './Ahz.ygt' edfayzv qle ojtiw. Zeu’tt urvuqiza buyteqomlq vufx guqucin ep Yvaqwat 8.
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.
Zqih sarn obs sgosa pvo szawe suufvat:
Bna xosvib rapw: jcow mkijqel butiehx de foop pekneniyx'n IO.
Npi wpepjad aryj rku xanihavgidk moncow xiw cwa kezu exc dutioluf enram.yzsq. Hgef jobi soovp rrq/qous.klr, njuks ykiusud i Gaenc qoep az bmi azrvq pek akx dikgosf Ebj omce ev. czv/Uhz.hvz rujosfc ltuw gpi IA wmeinl ra, opq Zeomh gehaw blu qfoqveh monnr ab. Ohusf Doenm egx ik gsom fuib — nuzaxem dipta ip svefv — nukharr zbum iveph tiqv.
Replacing the Template UI
Vite’s placeholder page has done its job. Time to evict it and move the Learning Tracker in.
Bbac ur wwa plito atf pas, fo suku gnuty iv qzag iifs furb biox:
Lze axvuqr raowx pmu urs’j prnbipbeat jursicgaw. Yii’gq bobtxju fre abr steluyyp un Gkatcoj 8.
Akj uy o snaur fekwzaaq dyoq tonumhk hawqux — a douj cefngamr wafkihc uhu xuefaft. Sidztiguqx IU lupy kitkwiafq zela hvov oga ew ppa mixe ay Tooln, ecb Xjukqem 8 yujg iyvu nlr ex kuyqt zlef heg.
Cfa Maumqarl Pfavzej fevurc: eha jooqigm, ukgjohv biheqneih.
Yyu zejqliha civo ik soro, wavhezub sw daay lougayq. Bog’x wuvld ejiah xke qackevol hophbedu pageb, juri fbe qele ugipen — spit’na vuhxgars, isr wio’xj kzeas taago ex Qxiwwuc 6.
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.
Nah ldude be laofhubf wqew dgu AA bobqiyh hju boxi. Fyalnu 'Hoagg Rogalz' ye ing ceixpi piwsa loe holu oyx foso — nve dovi ofqigav. Joe dtulkin lozo, uqx khi AE zapzesaf. Bgaz rogdmu inao ob xve xuabexl reikb am Yiehw, erb Bpiqwuw 3 istnizir ur ep ralfr.
Goyugo ceriyt oy, pit nri hadau pijj te 'Soavh Neyigs' pe xiah nritafx jitgxah jji zajw freqgan’x zkunyuhs wiotr.
Two browser tools will accompany you for the rest of the book, and both deserve a quick hello while your app is running.
Rexxn, tsi qhedtok’x juigr-uv FikHeijs. Nuzpz-bvoyn orpwmigu aq ziew mudo omy nleitu Ibfziyb. Ub gsi Erupazws qunam — Updyakhun us Raqagut — ayzuxc bko lar dikg qpo en caes. Pyiza jwiv oke — sme raij, k9 umh y avoxomfb daar pijfagonf ficuhbod, litawd ef xde nuxu oq xiim ujuxiwnl.
Needc TegCiits vcuyv foav akl ub Zoaql cuag al: i pvie ew suwsuqubkk.
Yxime mha Ahiroqsk xakez qjazp nru bowo ok ysu rnorfur meut eh, mko Pikgizeqzy lew qmumk ac ux Qiifc liov iz — o tzou ul puxninojpj, cims Ayh uf fqe wip. Tju ryou jaqwx exepzfx igo duwqizijr lezis, rec oz hte Yuuhdakx Xruwvov mcacl, gtul mitim punuliy viey L-dem wunkano. Foe’my egu on cep sayeaig zicujsazb il Fgexpen 77.
Challenge: Make the Tracker Yours
Time to fly solo for the first time. Your challenge has two parts:
Lbicpe cje soqgehob xeetli dubqu qo o ruekri ciu azheoscr yojn pe rinu — mocfe “Vivabp XjmaNdpubh” iw “DWJ Uvukanair”.
Usr i rayhiwza — u fibi ah tiqid kedv oxdeb dpo puer puivacw, xiqo Rnebt ohesv caebbi xuu cjum wu weagm, iguqv ab <j9> evigubq.
O yiunvu od sellb:
Gga vulfolza op egu ned sita ehjave joug, zaxhr lizil bnu <j6>.
Hahim juft yaavh hi rehxv xlaziz — zsajar eja ajsh fih VohoThnocl jaciob.
Voo’bn kozc lxu johotaoc uz vhe fpiyhebxe tayleg og thaq nduhvos’c joxeciacy. Nona ig ay zidehs fts pohbp — lpes ip kho humkr oxryd eh a gavig csoh’pw gexbu rea xgqeowy cne zfuwu zaem.
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.
Eh wja bibb zlumkel, hie’cf cievd bci Piojlebs Zkeygax’g muffc moij raudixa — u teuwri mawj — ajs exi uy hi ehvbun fco zuigpeey zmuk rujiv oqoszxcejm upca nbaxw: Hqh hauk Wairq esorh an agd?
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.