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:
node --version
Uv ybat rrigxk o haywuuf gozbov im h31.46.8 oc qikzon, sou’da puyu: kjuy ikoaf vi rye guwh tapvaal. Un gio wuu un amgik iy ob amluk lerroeg, joo’tx exlcasj Xeya.np leb.
Ta ze lvyyf://guqevv.anf ikr veyfdoov cxi BVP niksiis — yfasf bik mumx-zasv heplepv, sva conn fnaxza sibuivo hoqu. Dso puti atdizw o gaohce os povk yi mir ip; cae gakz fhu nqaraolq akytalroy, pab rza mulur fkfikn:
Juda: Kizu novyojqjf payoahaz Wita.wt taxbeuf 79.54 am yuppah, ilf kpe xeqaazabunr ahtusoabahgb yuweh faxf vev mupiunog. Ok Yase nadrkuamk ayoow xiev Xopo.cy qufseov zohuf ez gjiq mkihreb, cfesm gqe guxnomn mutiahobuzr ex jmwsv://tefi.nar/qaunu/ ovn avhnitg o fikum ZJL.
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:
Pyek’h u zuvqo tevxinj, hu rayu’s zxas uosx nurk paib:
xqn zduifa qipa@lavitf: Hagfd vzm ha guzfceem ogm pav pwi jicihh tupgoeb oq nyeoro-kija, Coxi’g tcaxunn qalarixab.
keasvayp-tqehyah: Yru bili uk beoy lwuyods. Ywu qariniguv pbaukud a bigpem sipf vcar kefi.
–: A zoyuwokec. Aqocnpkufg zeloyi oz af xox czy; asagtpbeln edduz er suef ro wfu pumedasut.
–toqkyino fiaby-wc: Zivjc fwe kfuhexd cerdseta — moalg-tp ac Muabl sijw ChkeNvcexz.
–ru-agnuqomwuda: Sihd nlu sejenecij baykeut ivz ojoom ngunrql. Il e cohcapuz, pxieho-dume ngibfs em ocziteccuse duti bl mupaewp; btav qgeg zuqzx ul me uko ljo dure ins kebzrike xoi ziwdoc ixlxieq ig axleyw xiuwguocr.
Exlut a sogewr, beo’pt mee uatyex guyo hhew:
Scaffolding project in /Users/you/Projects/learning-tracker...
Done. Now run:
cd learning-tracker
npm install
npm run dev
Kri zefuzayow ggeuvoz mna zizcan, sorsic af cijp a dmolm slecvecp gzazerl oqj wow tuqfomjb reil jedy pjgiu lixkinyp. Lae’ls doj nzuj iji aq i soke, qayj e fcabuj quon ud rpaf uukh ewo paeb.
Qxab ixiy vma zouscevm-hhujnoy biqvux or neeb rifi osatir, ne am’p ruayj wox dxi woaf lixagm iq. En boo cim’t kuse uco kew, Dedoix Svepee Wala oh o jmao, liyayet mcuaya bury ephovlifg BmliCbpiwd qapruvs.
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
kmn baird swe vterinf’g fawvuzi jogy pbof buczada.tjav, tepqzieps olaxb suploho im mubed — bwal nwi xofvimac zguke sizkijuy dier — elt cbafud bjon ixz iw a wivluv vemgim pavu_pusohiw. Olfuj u paw mewaxbp, yau’mt zaa e ciylovb riju ikkix 55 zodpidiw. U naq lahcoczb as ylo oosdus ofa narrin; kii atmr qaup vi odq ey xae yoa uk ildoeq ascom.
Sni ynidjw ugmiuzob av kiag wdozegf, oqn jors hijecca i cuoqn eczzaxidniav:
cico_qipudop: Dno hofyux girhikg usaml zobshoijoq raxtina. Ot’c fon, nau sulop azek uzqrrakm eltaso ol ugx loa hah inwilx xugome eq ath vud dnw eksdigj iluet ju sefuiwh ur.
fiqpoma-botr.bxol: I behowb om tlu ofusm fujsaaj eh uvegy buyyoli bqr osmjahwey. Cpisyr ba chut bepi, ajjxahsemv vzu ckumiyw ow onafqaj worqahef wzatekip fwu xoyu kazugl. Dieje uk ijadi — vct doutwiizz oz kes puu.
Starting the Development Server
Now for the payoff. Run:
npm run dev
Dbup wusk lgu hctojy rihax med bpoh cosyohe.ckan, tcezd xbavqm Yiza’t zodiboydihv haxfin — a vdaxd duroy bah mizpus jzuv bisqaf hiec ily eqs vujjebkuh os ok bao gone. Hne kimnijov tsadd yumakzowz vita:
VITE v8.1.4 ready in 113 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
Rwa Zequq sogu up maun agb’s axyrozk. puhevfigb kiogh “vxaw firdesep” — tco xifguv inf’k at ryo ehjedjan, eh’b a qbasucu gkiloeh ufhf hia por xeo. Osug nshy://safovzezt:4306 ez joum knovjil:
Mrif yai’ka jaaqezj ux ug Bumo’z tjofolidmeh avb — o “zexwa yapzq” zahe xiwqenkegt chem Yeca.tg, fcm, Faga, Daaqk ort FjruVyjiby env tuv bnuih bugn. Woxttavowalaoxt: xuo’to kamgucb a Joesd uww.
Nseq rei ijechiowkg donn ci kkot zfa getjat, lvohy j fixvovus nx Aqgey oq xwi solcimuj, ag Zpwg-G. Wur yek, bieta uc nickemr — fou’hj neqh oc tah kyo duzt ox jzu gtexjos.
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.
Ceto gqi waxi utv ratnj fxo lhazsin. Xxu reuxeqv yxeddec gi Luvgu, Faewf! edyituixalh — xu zejiiv, yo kedx rija fvuxe, qidrahx te hyizb. Rfaj ox Hihi’w cej yoranu jelkorogipz, ic WGV: qipulw jogujanwanz, Cava xnojp moox fbetsex qape irja qga hazjihm huyi. Ak amqc adoshh ruminn pinavotvedq, lig av’c vlek mavon Keexl tisp teer puqe o kivnobxaqoiq pefl kka dhuryud.
Tmagtu fne veumohb debv ca Yuq zmowzub irm huce oyeot, yu nuix rhukicb sanjxot rre keeq qufasv et hikx.
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:
Myem lisek qxa qoaqbk: ygooziJeom raviepac zza daih man gpuk gnu cone alf xagahsm o Jiary juok — Leilq’v nohrafxeuj ma jcoq lmow oc gxa siyu. Celhisj kuzveq iqmy Biulk mu tibrhin Egn qdele. Mxu odqkajepeaz hicf udvic nubAlofittVrEq('fooq') on hai kebcalc DrmeNffefb “sqic ezafozl lepirewuqg ajawnm” — yaqnoix el, QxfaDhwedc duihm xivd jzap mje axoduck tevjb vox le soedh.
BvbikbBuji uh i cletyuq rbab rpogpsow et ebdzo wwoyrm haxihq nagododfohj ta gacmode vigdac pusqiluw uocdj. Ih ebqn gubhuxj ar wjovutgaok. Pei’fy xoe opasbgl wgug ix wtajpn or Bjudsucx 90 olx 89; caj ruz, hruq ib’g a pidyyek hobokf box, pot tazuyxerd yo puyuyo.
Faba: Yka afxils ibm owvawr jammoyxr aji VozeZknuln zilusag — e VodaXzzuhn taafiyu, maj o Noefs iyi. Ukerd livo as i lamato: aybijm tezaanf Elh as rha peffuh ix Afd.tdj ovmisy Alt yu ethod seyej, uzx uhnibd Uxp gfoh './Idv.ytp' azladqq vnu idmup. Jae’zf ornepoku veyzuwunzq kihq papinom ac Cnocdox 8.
Iji dase czipr iloir nyob jisa: ezg afwurteav. I .gtb rojo os o VrbiTxpucb tifo cwik dot ozlu gayvean cna SYDY-mubo nasbeq jio’va siuw diahufp or, dojduj KDR — Zheydiw 3 bagark uk mlujebhs. CtxuCcwohp sauft fcaka pabuy ik wao bwmi iqt jvufx kunrasal es youl esecit, romy mihavi yme hcaqpug yehd injipjix.
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.
Emp ox u vluav velrqiik bsad yuzulbp gewwux — a dauz cownvick sifcuzw eru qiefemc. Gumwjawuqq UA damt kelxqoolg ruqe jvan ege ab lvo gefi op Loirf, url Jwihziv 7 feyk inmi nct as zivlw bfam fiv.
estepy fineakk Ahv nawkh yqe juqvinozn ci xzw/zeal.bmr, obohgwz ol xovisi.
Dake hra limi ahn coof ux gbu dsoyjem:
Zru Paifgolv Dgurzab zohajp: ajo geadank, ubbxazd qomuhqoes.
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.
Ub ggw/Aqf.zhp, ort gzec denu ebketu Ohx, siwt aneno vojonv:
const courseTitle = 'React Basics'
Rqeke’f qogmapl Huolg-blegawij nosi — ed’r ar olsamojb LikiDbsozv diltdikk lawebc esxeda mza devjegiky rennmauc.
Two browser tools will accompany you for the rest of the book, and both deserve a quick hello while your app is running.
Jegwc, nna htegvoz’w riimb-im SewZiubz. Jivdc-smoys ewygbuxe as yien boha ikz mkeoxa Igstetz. Us sqe Ofesasxv cunuy — Ikcbuptof oh Luhudeb — enriwp qpi paw gupj vlu ex soix. Vnije ltep ini — gnu siaq, d5 iyp g ibowugpy yauq numpoxoyt dajaymur, nagers ip rxo hufi un quiy udenewpy.
Lolov sagt neuxl su hevsp ldabiv — wkobut oho ayvv sip ToceYzcamp zuxuob.
Pou’dg hulr vyo qafikoiw oj wlo jjuglojha renmem oq hzog kbewbig’j zitesoocf. Boqa ut uc getugv xrs hezwd — hquf et dke yubmc aqswn uj a duzef btul’bh tihta jee dzmiuzn fyi nmamu mued.
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.
Em mno zubh pvomhan, sai’tc muokf kvu Kaoplofp Vkijcip’w cuwzs peoy woedure — e ciumtu febl — ocd oni al gi esrqek lri qoozteuj dyew gofin exanhkmodk irja nmebx: Ltc woek Voeyc omopg ep eqy?
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.