Interview practice question
Protecting routes and handling session expiry in a React SPA
Frontend Engineering · React · Experienced
How would you protect authenticated routes in a React SPA and handle sessions expiring while users are active?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Client guards are UX only; server enforces.
- Route loaders/guards redirect unauthenticated users.
- Handle 401s globally: refresh or redirect.
- Preserve intended destination.
- HttpOnly cookies over localStorage tokens.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.