Blog

How to Build Accessible Navigation in React and Next.js

Build accessible React and Next.js navigation with semantic landmarks, clear focus, mobile menus, active states, and keyboard support.

ReactNext.jsAccessibilityNavigation
Outdoor map providing directions and navigation information.
Photo by Yash Mannepalli on Unsplash

Navigation is more than a row of links. It tells users what the product contains, where they are, and how to reach the next task. When its semantics or keyboard behavior are unclear, the entire application becomes harder to use.

React and Next.js provide the building blocks, but accessible navigation still depends on deliberate structure, responsive behavior, and state communication.

Start with links and landmarks

Use links for navigation and buttons for actions. A control that changes the current URL should usually be a link, even if it is styled like a button. A control that opens a menu or changes page state should usually be a button.

Wrap major navigation groups in a nav landmark. If a page contains more than one, give each a distinct accessible label such as “Primary,” “Account,” or “Footer.” This helps screen-reader users move directly to the relevant region.

Keep the link text meaningful outside its visual context. Repeated labels such as “Learn more” make lists of links difficult to understand.

Communicate the current location

The active destination needs more than a color change. Provide a visible indicator and expose the current page or step semantically.

Match active states against the route carefully. A simple prefix check can mark several items active or fail on nested paths. Decide whether a navigation item represents one exact page or a section containing several routes.

Breadcrumbs can help users understand deeper hierarchy. They should reflect the information architecture rather than merely repeating URL segments, which may contain internal or unclear names.

Make mobile menus predictable

A mobile navigation trigger should have an accessible name, indicate whether the menu is expanded, and reference the region it controls when appropriate.

When the menu opens as a modal overlay, apply the focus-management principles used for dialogs: move focus into the menu, keep background content unavailable, support Escape, and restore focus to the trigger. When it expands inline and pushes content down, a full focus trap may not be appropriate.

Choose behavior based on what the menu actually is, not only how it looks.

Preserve keyboard order

The visual order and keyboard order should agree. CSS can rearrange navigation visually, but focus will usually continue following the document order. A mismatch forces keyboard users to jump around the screen unexpectedly.

Dropdown navigation needs extra care. For ordinary site navigation, a button that reveals a group of links can be simpler and more familiar than implementing a desktop-application menu pattern. Do not add arrow-key behavior unless the component genuinely follows the corresponding interaction model.

Every focused item needs a visible focus indicator that remains clear across header backgrounds and active states.

Provide a skip link

Repeated navigation can contain many focusable elements. A skip link lets keyboard users bypass it and move to the main content.

The link can remain visually hidden until focused, but it must become easy to see and lead to a reliable main-content target. Test it on every layout, including pages with sticky headers that might cover the destination.

Handle client-side transitions thoughtfully

Client-side navigation updates the page without a traditional full reload. That improves speed, but focus and announcements may not reset in the way users expect.

After navigation, confirm that the new page title is meaningful and that keyboard and screen-reader users can identify the changed content. The best focus strategy depends on the shell and route structure, but it should be consistent across the application.

Avoid moving focus during background URL updates that do not represent a new page, such as changing a filter query. Preserve the user’s working context unless the interaction calls for a deliberate transition.

Test navigation as a complete system

Use a keyboard to test the header, mobile menu, nested routes, breadcrumbs, and footer. Zoom the page, increase text size, and try long labels. Confirm that focus never becomes hidden behind sticky elements and that closing a menu returns the user to a sensible place.

Then test the route transitions with a screen reader and check that the page’s title and primary heading describe the new destination.

Navigation is a strong candidate for a shared app-shell component because it combines layout, semantics, responsive behavior, and route state. The responsive app shell guide covers the broader structure around it.

Enjoyed this article?

Share it with your network