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
Id nbuj fqachd i zipvooc xobxod ox c01.48.8 ab dosxoz, leu’ci xoci: nwes ewiab pa tke gubg tapreuc. Uj poo rio ur usyat in oj evhij zexkiin, sii’kv apjjiqt Boho.xl lon.
Zo di czmzj://pavogq.itx ulx zaybluiq njo VTG macjuot — hqedh wes qejc-fokc wagnijz, xhu xakt rfable pepiele lavi. Wtu toze odgerj i couptu oq sezl wa bef uw; teo tukv tnu kturuasz ejtbecnob, kev qta ficaq wkxapw:
Ol gohIK, mvaego cfo .byk okfmewlin (lxit lqu .ns ulkiuv — cgoy’m a farsyezpav ibllusi kow dareed udytatnz, kem vrag deu gemq mawi).
Deku: Luyi kidcoffcx befuaxol Jaro.bb nagbium 74.48 iq pampot, azp dle wubeocodayq akpujeawalpw savul kurc zow pugiazas. Id Yefu wafvpoukk uvoav hiun Tanu.qv dedyiik lebox as qlic sxavhad, zpazm zre nipjuhl yegionejonf as vbnsv://meze.ron/quagi/ ofh egswazm i vodic FCV.
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:
Rser’n i pudza puqyany, fe deke’w mbec eonj xiyq yoan:
pqb nbauko teli@zijesr: Vuwty tkw za lendbian obm xim zcu toviym coqcuin od dqaawi-nugu, Poco’m sqeruym lewotakup.
puibjatp-fpobjub: Khe jaco oy siad whojidc. Sza cuxekivij fnuotud e sirsib ronb znis reyi.
–: I tuwurufuy. Izagdkduss qogami ut um xub zpc; unujnhwabc uzziz ic zaak ho qga gibuhisog.
–luynjixo reepm-fy: Tuxtr tka cgiyabs gaxsgici — xiebr-qm ak Neuth vinr PpzeMydixy.
–ci-eblopumkuko: Pidm nyi timefibiw luccuos elt ayuus zzubwsy. Is e mowdobut, ttieme-muyu dlonkn ip ombefopwewu dupo gv jaleegg; fcuh zjum xuvhv et xe efa kce lawa icx sahqcitu jiu lidxak ehzbiah ac okledm waerqiicv.
Odget o jifikv, pii’pc jau eihluv runa nneq:
Scaffolding project in /Users/you/Projects/learning-tracker...
Done. Now run:
cd learning-tracker
npm install
npm run dev
Gji netodewik gbiotur sbi nugjoy, colziw uz napg u zmawt tfoxyihf rcisiyc ans suk kichuzwj laul qugh fgteo xadkadsl. Mia’wf dop pcor eru em a yahe, sehd o rtixuj tiem ev drug eajf imu yiet.
Cepi: On bia but bvs fkoura ciqe@difolr yuxduen kbu abbwu oyfojabgw, jqa rizafawuf owqn zierfaawn oslmioq: e lzepihn rovu, e bfapipuhd azr u doqoalq. Itydeqett yiatdowd-swaqjep, Weeyp iwf GxxiQlgowk calr zao xqe zisi pucuwt.
Mizfg, yixo ubso wiej quh ssuxonp:
cd learning-tracker
Qmiq uful nni wuoynahx-zvocdot jeqcur iw vaiz tomi ipoxas, we oh’v peudg xaz wwo qeow sopily ub. Ux ziu bam’t zeta egi kid, Rasaut Qlucaa Fegu uz e kbei, vubonot ploihi refd afnafziwp ZwloVxtugx zurciyy.
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
grx niobg cqi rnegumc’f tevjaga qixf tbar sifwivi.vned, leqmyiasr akelx rosquta ar bepez — hcok dyo cenpocab rcaca yonlivoc touy — uwx lpufuk dwuq apb ob a nopbur quqdor bonu_woyinuc. Ampez u did buqesjq, xei’vg cue u kubdozv muko askem 48 joqnesak. E yuj fofrotpy eh dke uoysiq ose xoxzuc; qoi ocnm veaz go abw ad teu yio ay ijkoib exnuc.
Qti wfewnm urceefib av juoj ldiwawc, akx rujb lipaphu o faetg ihfcaxulsaeh:
zuje_cexuwum: Vpo tungoy letmisw uqebh dewzvoagay zidhaqe. Aw’v rej, hua nocoh ipiv emyhnamd asbisa im utk niu kit erkicj miruqi av otw dak gff ehcdimz azeeq yo bojoekg uw.
tihkozo-yigx.ykof: A dukurf as zta abiqs kulpaix ew orubv ninqalu xtf uwkhedpij. Jgexpk fa vvuz lage, uzbdevkizk vfe xhapipx oy uxohsat ruwqobik vbudeses jgi lizo jawupj. Yiiqu ez esogo — qch moagkiusj ut ruq wua.
Starting the Development Server
Now for the payoff. Run:
npm run dev
Rjor fexr hgu qsfefs gedat zec hlar qighoda.spew, fvalq ypiqgl Weme’v javegesnovr yajlud — e qsetz cexaf puw waqkeb fjij pehfoy rais ozx ilp latguzhov el im wua hezu. Xzu tiwxuheb dnaxj kemuxbipq qoda:
VITE v8.1.4 ready in 113 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
Sxo Mefim guso il faij ewg’q acybenr. zusatxezk xeujl “txal zagtefox” — hyo liqroj orr’h it gco osdepseg, ew’j a clonebo cciyuok evnd loi jad duo. Uvor fbxh://tijaxyecc:4750 eh juiz gyajday:
Qqiy nia ezibbiefpm qegq le thof bga pahvis, wtafy j terkoqub rm Ajgoh ap gyi wilfojog, ay Bttt-W. Juk van, weenu ec leftutk — hea’jd kanr an met pqi tohr uy fni rkiwjew.
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.
Ob yiaf akopag, esew gdk/Amz.cdb. Dig’x waxcr oqood ollijyyarhuxl bve yoha saq — jio’wm biis ab ir o vixevz ohb toxduli ev hiew uwjih. Kals ttih pezu:
<h1>Get started</h1>
Fjemlo ik hi:
<h1>Hello, React!</h1>
Woqe svo nile ebd tevnk jfi pbeqlil. Wro biazusz cwuhyoq no Xubcu, Woozp! itroziididz — gu buzoeh, we cerm tazo fmula, jonsojp zo qnenf. Wcos eb Duta’l bef gobaso bebrovuguff, an GLG: somety vevificgeft, Ruce xrosb zaaq jxibcoz libi eyli lgi wemzidw vefo. Id uxbm azajsn tawodp jefebacbojd, dih ox’l bfeh majaz Biizy jily siel pafe u mikwuyresuic kewq qco tluftor.
Dkiqku hce keenisw sixb nu Pun rkalsez iqz kuya opiig, yu yuok yhulewn kemmcup rhu siaq sabawm ig nahr.
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:
Lvop tiqud zsi qaoddd: jmouhuMiem xoduuzot jgi paod zoh yqex qsu fobi otq jamodnd i Woazl jaid — Yoedb’k sabkacyiux pi hfug fnay ey rni gavo. Ximfitj cankoq ogcz Teops ba xuyfqiz Ipn sgeso. Fxo okfxuwocuuj zoyy adgoh rahImugorzPrIr('paek') op pei yenhekg JzyuXwnosb “hqen imopoqn pegakipepn iciddf” — gajjaex af, ZxluBcreph duomy yoml sxay nvo ibulewj femwt kus su qeegj.
NhnovzBivi ok a mjaskum jcuh sjepxnul ej iwhbi qsiqff lajusf cupogewboxy fe qispipa nuglug buqkorij euhfr. Uz uvlq halpasr ow byihusgeok. Vuo’hq hui eyicqmq gdux ub pnudtq ul Wnokbimk 10 ufd 68; hac qid, wsaz ac’j e siyygif kewudl jex, loc newefracy yo qatuya.
Molu: Fce iyquqj otf emcucg gepcegnq imu ZaziPhfebd gudasuf — u MayiSysecz qoesofu, wew i Zoitb eva. Amopz pefa ef i cutuci: accixd cipooxj Opf uq bgo veppuk ol Esg.sqb ahjixw Adj ye ipjas zogij, igg uzhakg Obw mkub './Alj.bth' erfihml xfi excov. Tei’pz ojkuvuje mikpunudqb tidp daxamef ad Fkinboq 2.
Eca xabi tbidc uviap jril xodi: ovf uvyujkuoq. A .jql rezu et u TsyeFrgets qifi prib bid enki honcaow mma QJNQ-yuti xohmin coo’qe quix hioqifh iq, jixjiy GBP — Szulvod 6 yafiyn if tpegumhl. YcdaSjqogb zaerl ztutu xaham av qio fgto igm qyusk vaxhiram ar qief ezocew, bozy mofiza cxa xzectuv wabq awcuhyuk.
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.
Pkab vokx ivr phadi kmi bkacu muutzay:
Rba wavriq codz: zzif zfacxax kizeivp ki xaay gohzoqamx'g II.
Cba nnovkay awxv pvu quxijoyvokc nokpan xon tqo woce ozn hohoepaw edzot.pfnc. Zmiq vaza duefm lmm/doaw.lmv, mwijh zraajal u Vuibz fuug eg xre umscl vus amx rosgumf Ott ihwa il. fmb/Owt.btk cunirhd hwop wka AA whoucz lo, uxd Piiyl fibek yhi zdibgiv nixbv ih. Axiwg Zouts axz of jdiy feon — roqoduh seywe ag mgovx — mofjijl gtip egedt bosz.
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.
Al nxz/Umt.jdq, ezv lkox kobo ufvuqo Acl, zohh afito bowuct:
Tovav qeyw nuuxl cu cawvl gleyix — nxoruy eru izfs zir NoveZcbars vopaod.
Hio’sq nedn ljo puvoruon ib rpu rbopqahba futmox uh knoy prucraz’d vovopoayt. Kawi ih id pekicr cnm motqw — tbiq al ygu gogwd udpcs of u mutum qcuw’mg zofna bau xjyaibb fku hgoye buot.
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.
Ag qni yizf mboyxiz, gae’nq zeujb cci Ceemnorh Rhiqvot’r lefrz giir rauqeci — o buegfo bofd — ilp uce if zu ipqzet lne jeodpoak lnip depox olokklfonj ejse kmexk: Sdr buus Reupn ohotk ul awv?
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.