Security in React Apps
Defend React apps: how JSX escaping stops XSS, safe HTML and URLs, secrets and tokens in the browser, securing Server Functions, CSP and dependency hygiene.
Security means making sure your app does only what you meant it to do, even when someone sends it strange input on purpose. A React app runs in the browser of every visitor, talks to servers, shows text that other people wrote and pulls in hundreds of packages written by strangers. Each of those is a door. This phase walks through every door in a React app, one at a time: what the threat is in plain words, how React already protects you, where that protection stops, how to close the gap and how to verify that it is closed.
You'll start with XSS (cross-site scripting, when someone else's text runs as code in your page) and why JSX blocks most of it by default. Then the escape hatches where it gets back in: dangerouslySetInnerHTML, refs, unsafe URLs, spread props and server-rendered state. After that come the things the browser can't keep secret (API keys, tokens), how to store login state, CSRF, how Server Functions and Server Components change the picture, and finally the supply chain: npm audit, lockfiles, Content Security Policy and Subresource Integrity.
Everything here is defensive. When an example needs untrusted input it uses a harmless stand-in that only writes to the console (this would have run), so you can see a dangerous sink execute and then watch the fix stop it. Every live example runs real React 19.2 in your browser, and the exercises check that your fixes really hold.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.