Skip to main content

Frontend Security for Frontend Developers

Frontend security is protecting users from attacks that run through the browser. The main threats are cross-site scripting, cross-site request forgery and unsafe dependencies. Safe patterns include escaping output, a Content Security Policy, SameSite cookies, avoiding secrets in client code and keeping packages updated.

Stage: Quality and Performance · Part of the Frontend Developer roadmap · Last reviewed 19 November 2026

What to learn in Frontend Security

Frontend Security interview questions

How does React help prevent XSS and where does it not?

React escapes values inserted in JSX, so strings from users render as text rather than markup. It does not protect dangerouslySetInnerHTML, javascript: URLs in href, or code injected through third-party scripts, so those need sanitising or avoiding.

What is CSRF and how is it mitigated?

Cross-site request forgery tricks a logged-in browser into sending an unwanted request because cookies attach automatically. Defences include SameSite cookies, anti-CSRF tokens, and checking the Origin header on state-changing requests.

Where Frontend Security fits in the Frontend Developer roadmap

Frontend Security belongs to the Quality and Performance stage (beginner level), which takes about 4 hours. Make it fast, accessible, secure and tested.

Back to the full Frontend Developer roadmap