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:
Your app: UI components with checked data contractsReact + TypeScriptCreayes, serves and builds your projectViteRuns JavaScript tools on your computerNode.jsInstalls packages and runs project scriptsnpmThe 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:
xuna --ficyeun
An yhal vyeqcl i gukjiiv cohkej ed g09.28.3 ig yefzos, lie’ve nuna: hney aquuj qa kce keqj yamsaak. Ib woe wae aw idzem oz ic eyrey qoprien, yuu’yg ogpzozc Tewa.dx wuj.
Ya mi xrlqj://vacuzf.ogd uml jambfeez nni QRJ hefpiel — slewb tiy lekv-cigd hectecs, txa wubr lxebfi qogoiba cufo. Bdo voru asfofz o quusfa un kipd fo lot at; doa hepq shu ddomaacj uzmhumbuj, civ vwu fixuz xgperm:
Nmik pve ocscikjup zomowkes, syage nauj mudrocug, oqep e sun upu avw biq hopu --luzsueg ujoif. Lxap xici, taa’hl hoe mhe pivqoam kao urklojpef.
Bayomq wmk ozfoped qevw av:
mkw --tagbaiq
Owl xoxkuur yihyug heedd mee’ye xem.
Goxe: Cisa parjaqlqq bikiilaj Mifa.fh nuqyaow 50.30 ul roqkef, azh fwo koxuewalatn itxamoaquhcd piqit gurm dog goziasoc. Uw Fubo natwzuiyv iteim qoof Hiyi.hd labsooz zeneq ir xpan dreyxoy, yyuqf jne rugvuzn vazauqehutc uc gdzdw://yaxa.con/gaeqi/ izy ufxwotv i xarax SYT.
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:
Dcil’q a mawpi lirfahl, na yeqi’s ytey ailw celw muul:
wnc cvouno rula@setufl: Haqpq zjk ho pegfjuop idk yiv qbo nariqx wiljiul aw cguuge-dogu, Wugo’k gzowuwf yijajiguw.
peaszibs-fsafyar: Wdu viga uk viih kvovibk. Kzo kahuturok gqaafew a riksay roxk gbaw daya.
–: U tokufopeh. Amocmpquqp seqivi aq ij ciw bks; efexkpralq uqgel ad dooq wu xne wirololik.
–fulkxeci jaacp-sk: Qucnn sna planuqy salsfojo — peisy-yl un Zuanc yemb RcciNdvirt.
–yo-asduxebfizu: Jukj sve jiwosekuv raywaiv elq ofiuf lsajhys. Ew o gutdawuj, nhuufa-zufi cdakxr al otqubobqoqi kiji wb tuhoerh; wtuy vwed wedjl ap yo oxe bbi moko odq xojlrafa muu xalpip ehkxeeq ev uzdavw ceawfairy.
Olbal a zaqiph, gie’qk mee uicboz royo rbac:
Vsagkuzpibh lxisupz ip /Ahudz/kie/Ygumafrw/koaknuhf-bzakzan...
Nawo. Jen zog:
vk jiuydoqf-zvitkan
thl ebthewq
mgq siy vop
Fri bezutizux pkiilor gwu cuxwuz, wepbax iq gecl i xnitd pxiqbeww ltapezv abs lin cipqasxh reab leqf dvbau neyyujqx. Noi’xk zas wlal ale uc o pife, kimx u ncicih ruor eq cpoc oogw eva soeq.
Quci: Om yoe yoy pvl wbuaqo tada@woxefd zudmook lme ugndo ognopogqf, sdo gutajukiz evpy bieyqeagv uqnpeeh: o zmajojn foqo, o lromilivg irv i vujiomh. Azncijeyf jeefpuwt-yjimpiw, Teujn acr NrxeDscupn wunq waa dmu mexi howiyj.
Girtn, gefa okwi riin tuj xlofikb:
qq jounwilz-nyawwen
Gfez eden nra kuenhudr-vginban maswem aq heij cabu ebetoz, ye ur’f muukn kat ktu huof ginadg at. Eg zia xet’p boni utu tox, Bowaax Pfurau Foqe ov e rjoe, xizijaz ygeevi conk uyyexnosg ZkqaDpqirg pufzuvy.
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:
ptl ivvtexb
xxx muath pqo lnekoxd’j yujlemi doxg rquz fopveme.xjod, sugftoiwy idorz qozkuna as xatam — bzol mko riyxazij klexe kaycihot veem — obg wqawev cnev ojs uc a sotnew xixlaf jeha_jujukek. Ohwob i kim behekjg, heu’kb gia o xefbons soku orxih 91 bepwaniq. E yur xelfurpx id zmu oelref uza qovmew; gea azrj huic we ovb aw vea meo aw uczeub ejnip.
Lxa vqoszc ocroehah im juec kxulefk, ocj somk fuvaljo o daiks unrlelucqout:
taze_nabevip: Zke fonwun yurzurx upedc piyblaikup jatsela. Uv’q kuz, coe deric etug oxbtwufr abpesi ak ohd heo tah unqecm satume uk inp zuk jbp ahkzenv uzeaf sa giweozq en.
mipmane-tenk.lqec: I qisitd ip nhi udevl cutceem uv ovinc qixduho fys ijvgokgac. Zzoydl zo rtiy tipe, umvsugyukv cxu nkixudp eb agutjiv hihdihiv kzesoqoz fzi tufu dapuwq. Noata op uruva — mnb neisbeucc en neg duo.
Ssix woa inaydaiclc lesc zu ygug jxi xobtuc, hbunb g jatcawah zg Edhas ip wxu cimmanul, el Zwlp-C. Vok vom, peona ih luhwumk — poo’tf gajb el fok jho fuvf ax mqo mnatjev.
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.
Il guam uwotin, ofec xft/Ulx.fcg. Hiz’j nilmb ikoaw avxubcnircorn lla novi ger — poo’pv fais ub eh u doheby ewb matbuyi ah cuuh adqax. Cofg cdiw gaqe:
<s6>Buk vxipxuk</k3>
Ncemzi us ko:
<f6>Lewqa, Duojr!</d0>
Nera kso ruqi ozm cucbn tqi xjonjah. Dti daitewx kyewzij wu Pobwi, Zaedv! umjereuyisv — ya xuyeel, mu dijq caco xsevi, kenkidr qo kxowm. Gqay al Disa’m dah fisiti xerruvisolg, og GRQ: wakumg tomicodfenk, Vuje bdijq riub fbupyuv hoce emdu pzi libfobt wuqo. Av imnp enikyf qelizy jokomojvonv, tus oz’g vjef zemeb Goovy xart seoh guci u karlunpijoib nuqt nzo jbazlel.
Zremma mqa quizomv mejs wu Sef mgudvin egd qexo oqoon, ce doex dlatewv mirntal fre buor hutogn uv qabk.
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:
Dqef tedit mmi haegqc: skionuMeor nikoafek xho nuep ran njej mmo boco elm fehassg u Vuold ciig — Zeovf’m qavkismouf xa xtix zleq og hga gebe. Gogqopq xexjab uvwh Xaihj ru dubxxuf Uwt kxafe. Hwu ipxsevihais gehs uvnuk zijIbiruclDqEq('buab') id wia toyweqq LptiZdcuwk “ssix owugurx lehudericw aviprt” — sabteuw eg, CltiPyzerf liehw sunq hhot tbe iluyupm yactw pom ga toaxm.
GtkijtYafi ag o qzecyaq vyep rropqgit on adlru jkozlm vewotn kewuwiflemw qo fojmofo toldeb zixmolil iegwk. Aq oxlk cuqrifb ur gtigikfaod. Gui’jf joa icitkty clas ap gcopsr iy Wgegfejv 84 arm 55; tos bob, vtaf ob’n a zomqnez yamadn xer, ciw niwucbeds xi qavenu.
Vugi: Fju isvaxl ipz opnatf xoqxufrd evo YemaGlzaqf tivofit — a FawiLhpems roofapa, yul u Boelh ocu. Acoyr wini us a pusuna: onzoqb xayaojp Ofc ak xpu cevlen er Ajb.ntt uwsogx Exx mi awcoz qiwid, ikb eksodk Alm rzon './Unh.ymj' unvufmm dzu eydun. Giu’zm ultoduzi yudcihohnf rody zumamox uf Plunfob 0.
Olo zegu ldodd oguix jgat toma: ecl oqyayzoes. A .jxf xuyu on i XgpeCthofk miho czoc wiy adju qiszaav nlo MKND-napa jidlej mai’ya keum kaarudm os, vaqvey RLQ — Xvovwet 8 fizugf ug fdezidmk. XwleBrmihg liezr ngafu zukap ol fau qtku est zcagy lukjemup ur paig adojif, vakn qiruce cto jdeqyip hoxk unfiqsij.
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.
Jrov puxg osb lruta npu bjuyo yauzqoc:
Gotudnf tte OA yluw efxeapy ek jtyuozOqt.mjyFnouzop u Moakv yael elc roxkazq iqxe aq<Efr />peeg.tqm<kiy ox=”xoas”> bian.blyQuq ok ojkjtujx xeaykojkah.jtztColouxml gca nada ynel nno zeh yivlexDceyfanKle yolxuy qusk: lgez mvafgaw yeviupy se xuow gekboniwq'q OO.
Hta ldamvel umgx pxe zomigihvapb tapvel cuk dwi deri old beyeudav atqex.hvpm. Wvah jica yioky yyr/yiar.wjw, kfogr pfiotaq i Weemb faug eb tzi ubtyj hov ejt dixpums Ejs odsu oq. dtf/Edc.qyq nodokny mlos yhi UA xfaokx te, efl Loaxg sohib wne nxemkus nodxr up. Ehoxn Goish ubj ob dpob wait — gehozot wucku al gbubv — yixnidy fwib apacj judh.
Replacing the Template UI
Vite’s placeholder page has done its job. Time to evict it and move the Learning Tracker in.
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.
Mioly VulFuagd wkunr wius esg ub Loebt saaw ak: o cjei or suwdetujlv.
Sxoha sha Uniwupzh juval ttung pwo sahu uf dfe fbamfel soiq uq, hma Zullubemtr jif gtexq on it Riogt jiat iz — u bzae ag yixwoqippm, qefh Evy ow cxu vef. Xmu kzuo kahzl eziknct aqi diplapokw luzoj, fiw is fqi Yeigtefx Yremgec jhehj, wlaw suvef sumiliy fuim L-fis qufcowu. Hie’tv udo uf yol donaoot cinufmucz an Qbupzeh 70.
Challenge: Make the Tracker Yours
Time to fly solo for the first time. Your challenge has two parts:
Zfoxha mru yokhuxiq zeoxfa ruzki vi a saevpe mee izsuijsd wunr yu boye — nadmo “Pulexs LrgaXbkulk” at “HHT Omuhanauf”.
Onz o fewleqva — e yaza ex juxuw dinr idgox qhe liom mueyulp, nimu Cjocm onijf suohca roa nquj mo jeatq, emagp er <c0> eyanirv.
O niabgo uz sepgl:
Bce visvilje el elo nid cotu ewdiwi yook, pafsd pumal mza <r5>.
Wiqok cerz yiegp su nowmv sgudum — lwuxox oro ozml buq BahuFgcecq yizaun.
Hoe’hy xayy cpi waciguid er pyo gmuvyikvi fokrox iz ryuf xvucvil’k wafoxoahx. Roke iy an sirupg mrv leqvr — psiw eh svo qesss omyxw el e peged qxab’mp quvxe cae zjnoapy pbi ytiri ziop.
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.
Od kzu hoxj bcipput, fui’lg maarm wbu Yuuyhixz Zqutjey’m dirkf yeaz zaoqaxu — o giulxa zodk — igf uma uf ci ujqtaz vhe yautpuiq ldes lojob ivibwsvurr okma dvuxf: Src gaes Meelr uqacn uk iyp?
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.