React Interview Questions and Answers
Simple answers, interview-ready wording and small code examples for React developers, including experienced ones. The guide has 245 frontend questions in all: React is one topic of 14, next to JavaScript, TypeScript, Redux Toolkit, security, testing and system design.
Reading the questions and answers needs a free account with a verified email. The topic list and the sample answer below are public.
Sign up free to read · Sign in
Where to start
Hooks and core React
Start here for core concepts: state, effects, refs, memoization and custom hooks (41 questions in the React topic).
Performance
Use this when an interviewer asks how you would find and fix a slow screen (6 questions, plus performance questions inside React).
Security
Login, JWTs, token storage and route protection, including why the backend must check permission (13 questions).
Free sample answer: Where do you store the JWT in a React application?
Simple explanation
A JWT is a key to the user’s account. Anything JavaScript can read, such as localStorage, can also be read by a script an attacker manages to inject (XSS). So the safest place is one JavaScript cannot reach at all.
Interview-ready answer
I avoid localStorage and sessionStorage for tokens. My first choice is an HttpOnly, Secure, SameSite cookie set by the server, so React never sees the token and the browser sends it automatically. Because cookies are sent automatically, state-changing requests also need CSRF protection. If the token must be readable by JavaScript, I keep a short-lived access token in memory only and a refresh token in an HttpOnly cookie, and I call the refresh endpoint on page load. Either way I reduce XSS risk with a Content Security Policy and by never injecting untrusted HTML. Where the token lives never replaces permission checks on the backend.
Code example
// Server (Express): the token is set as a cookie that JavaScript cannot read
res.cookie('token', jwt, {
httpOnly: true, // not readable from document.cookie
secure: true, // HTTPS only
sameSite: 'lax', // not sent on most cross-site requests
maxAge: 15 * 60 * 1000,
})
// React: the browser attaches the cookie, the app never touches the token
const res = await fetch('/api/orders', { credentials: 'include' })
if (res.status === 401) navigate('/login')Topics
- JavaScript — 26 questions
- TypeScript — 26 questions
- React — 41 questions
- Redux Toolkit — 20 questions
- Performance — 6 questions
- Testing — 9 questions
- Security — 13 questions
- Architecture — 10 questions
- Coding — 30 questions
- System Design — 15 questions
- Leadership & Delivery — 23 questions
- HTML, CSS & Accessibility — 12 questions
- Node.js, SQL & AI — 4 questions
- Project & Experience — 10 questions