A Practical Guide to Focus Management in Single-Page Apps
Moving and announcing keyboard focus when a single-page application changes views without a full page load.
On this page
The key figures
- No page reload
- browsers do not reset focus on client-side navigation
- Announcements
- route changes should be announced
- Headings
- moving focus to the new heading is a common pattern
- Titles
- document titles should update on navigation
Why this is worth getting right
Without focus management, screen reader users are left on the old content and keyboard users lose their place.
Do this, not that
Do
- Move focus to the new view's heading on navigation
- Update the document title for each view
- Announce route changes politely
- Restore focus sensibly when closing overlays
- Test navigation with a screen reader
Don’t
- Focus left on the previous link
- Unchanged page titles between views
- Focus jumped to the top with no context
- Route changes only visible visually
When to bring in help
Our advice Bring in help when client-side routing must be accessible.
Where this comes from
- W3C Web Accessibility Initiative — Understanding SC 2.4.3 Focus Order
- MDN Web Docs — Client-side routing
The figures and practices above come from the sources listed.
Working on something like this?
We take on Performance & Accessibility work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.
Where to go next
Spotted something wrong? Report an error on this page. We correct on the page and say what changed.