Accessibility in React and Next.js Apps: 2027 Guide
React does not make a site inaccessible, and it does not make one accessible either. React renders the HTML you write, so the same rules apply: use semantic elements, label every control, manage focus and announce changes. What React and single-page apps add is a set of extra risks: route changes that nobody announces, focus that gets lost when components re-render, custom components built from divs and dynamic content that screen readers never hear.
This guide covers the problems that matter most in React and Next.js apps and shows code you can adapt.
Why do React apps need extra accessibility attention?
In a traditional site, every link loads a new page. The browser resets focus to the top, and screen readers announce the new page title. In a single-page app, the browser stays on the same document and React swaps the content. Unless you do something, a keyboard user keeps focus on a link that may have disappeared, and a screen reader user hears nothing.
Other React-specific risks:
- Components built from
divandspanwith click handlers instead of buttons and links. - UI libraries whose defaults are accessible until someone overrides them.
- Content that appears after a fetch, with no announcement.
- Modals and menus that are rendered in a portal without focus management.
- Loading skeletons and spinners that are silent.
The relevant WCAG 2.2 criteria are the same as for any site, such as 2.1.1 Keyboard, 2.4.3 Focus Order, 4.1.2 Name, Role, Value and 4.1.3 Status Messages. See the WCAG 2.2 AA checklist.
Should you use semantic HTML in JSX?
Yes, and it is the highest-value habit. A button is focusable, responds to Enter and Space and has the right role. A div with onClick has none of that.
Bad:
<div className="btn" onClick={save}>Save</div>
Good:
<button type="button" onClick={save}>Save</button>
Use nav, main, header, footer, ul, table and real headings. For lists of links, use a with an href. Use button for actions, and a for navigation. See 10 ARIA mistakes for what happens when ARIA is used instead of native elements.
What about fragments and extra wrappers?
Use a Fragment when a component returns sibling elements that must stay valid HTML, such as table cells or list items, so you do not add a stray div that breaks the structure.
function Row({ name, price }) {
return (
<>
<th scope="row">{name}</th>
<td>{price}</td>
</>
);
}
How do you label form controls in React?
In JSX, the for attribute is written htmlFor. Use useId to create ids that are unique and stable, which avoids duplicate ids when a component is used more than once.
import { useId } from "react";
function EmailField({ error }) {
const id = useId();
const errorId = `${id}-error`;
return (
<div>
<label htmlFor={id}>Email address</label>
<input
id={id}
type="email"
autoComplete="email"
aria-invalid={error ? "true" : undefined}
aria-describedby={error ? errorId : undefined}
/>
{error && <p id={errorId}>{error}</p>}
</div>
);
}
Placeholders are not labels. Errors must be in text, tied to the field and announced. See how to make forms accessible.
How do you handle focus when the route changes?
This is the most important single-page app problem. When the user follows a link, three things should happen: the title changes, the change is announced and focus moves somewhere sensible.
What does Next.js do for you?
Next.js documents a built-in route announcer. For client-side transitions with next/link, it announces the new page, and it picks the name by looking at document.title, then the first h1, then the URL pathname. So each page needs a unique, descriptive title. The Next.js documentation also says it includes eslint-plugin-jsx-a11y in its integrated ESLint setup. Check the current docs for your version, since the setup has changed between releases. [VERIFY]
// app/pricing/page.jsx (App Router)
export const metadata = {
title: "Pricing | Example",
};
The announcer tells the user the page changed, but it does not move focus. If you want to place focus at the start of the new content, you can do it yourself.
How do you manage focus in a plain React app?
With React Router or a similar library, nothing is announced by default. A common approach is to update the document title and move focus to the main heading or the main region after each navigation.
import { useEffect, useRef } from "react";
import { useLocation } from "react-router-dom";
function RouteFocus({ title }) {
const { pathname } = useLocation();
const headingRef = useRef(null);
useEffect(() => {
document.title = title;
headingRef.current?.focus();
}, [pathname, title]);
return <h1 ref={headingRef} tabIndex={-1}>{title}</h1>;
}
tabIndex={-1}lets the heading take focus from script without adding it to the Tab order.- Skip the focus move on the first page load, since the browser handles that.
- Check the result with a screen reader. Some teams prefer to announce through a live region instead of moving focus, and either can work if it is tested.
Do you still need a skip link?
Yes. Add a skip link as the first focusable element, and point it to a main element with id="main" and tabIndex={-1}.
<a className="skip-link" href="#main">Skip to main content</a>
<main id="main" tabIndex={-1}>...</main>
Style it so it is visible on focus. See focus visible and focus not obscured.
How do you announce dynamic content with live regions?
Content that changes without a page load, such as "Added to cart", search results counts or form success, needs a live region so screen readers announce it.
function Status({ message }) {
return (
<div role="status" aria-live="polite">
{message}
</div>
);
}
Rules that avoid the usual failures:
- Render the region first, then change its text. A region that is mounted at the same moment as its message is often not announced.
- Keep it mounted in a layout component, and update the message from anywhere with state or context.
- Use
role="status"for routine messages androle="alert"only for urgent errors. - Do not announce every keystroke or every second.
const [message, setMessage] = useState("");
async function addToCart() {
await add(item);
setMessage(`${item.name} added to cart`);
}
Loading states need the same care. A spinner icon is silent, so add text such as "Loading results" in a live region or visually hidden text. See 10 ARIA mistakes.
How do you build accessible modals, menus and tabs in React?
Modals, menus, tabs, accordions, comboboxes and tooltips are where React apps break most often. Focus management matters most: move focus in on open, keep it inside for modals, close with Escape and return focus to the trigger.
The simplest route is to use the native dialog element and call showModal() from an effect or a ref. See how to build accessible modals.
import { useEffect, useRef } from "react";
function Modal({ open, onClose, title, children }) {
const ref = useRef(null);
useEffect(() => {
const dialog = ref.current;
if (open && !dialog.open) dialog.showModal();
if (!open && dialog.open) dialog.close();
}, [open]);
return (
<dialog ref={ref} aria-labelledby="modal-title" onClose={onClose}>
<h2 id="modal-title">{title}</h2>
{children}
<button type="button" onClick={onClose}>Close</button>
</dialog>
);
}
For more complex widgets, use a well-tested library rather than writing your own.
Should you use a component library?
Usually yes, because building keyboard and screen reader behavior for a combobox or a menu correctly is hard. But a library is a starting point, not a guarantee.
| Type | Examples | What you still check |
|---|---|---|
| Unstyled, accessibility-focused primitives | Radix UI, React Aria, Headless UI, Ariakit | Your styles: focus rings, contrast, target size |
| Styled design systems | MUI, Chakra UI, Ant Design, Mantine | Defaults you override, custom variants, labels you pass in |
| Component collections built on primitives | shadcn/ui | Code you copied into your repo is your code to maintain |
What to check, whichever you pick:
- Read its accessibility documentation. It should say which patterns it supports and how to label them.
- Test the components you use with the keyboard and a screen reader, not just the demo.
- Watch your overrides. Removing a focus outline, shrinking a button or changing colours can break an accessible component.
- Pass the labels. Icon buttons, inputs and dialogs need accessible names that you must provide.
- Re-test after upgrades.
How do you catch problems in code?
- Linting.
eslint-plugin-jsx-a11yflags many issues as you write, such as missingalt, invalid ARIA and click handlers on non-interactive elements. Next.js documents that it is included in its default ESLint setup. Linting only finds what is visible in the JSX, so it cannot see the rendered page. - Unit and integration tests. Testing Library encourages queries by role and label, such as
getByRole("button", { name: "Save" }), which fails when the accessible name is missing. You can also runaxe-corethrough a Jest or Vitest wrapper on rendered components. - End-to-end tests. Playwright or Cypress with an axe integration can scan whole pages and fail the build on new violations.
- Storybook. An accessibility add-on that runs axe on each component story.
- Pull request checks. Make a short accessibility checklist part of review: semantics, labels, focus, keyboard and states.
Automated tools find only a share of the issues. Keyboard and screen reader testing still matter. See the keyboard accessibility testing checklist, screen reader testing for beginners and the best free accessibility testing tools.
What are the most common React accessibility mistakes?
- Clickable
divs andspans instead of buttons and links. - Icon buttons with no accessible name.
- Inputs without labels, or with placeholder-only labels.
- Focus lost after a route change, a deleted item or a closed modal.
- No page title change on navigation.
- Content that loads with no announcement.
- Removing the focus outline with
outline: noneand no replacement. - Using
autoFocusin ways that move focus unexpectedly. - Duplicate ids from hard-coded
idvalues in repeated components. - Overriding component library styles until contrast or target size fails. See WCAG target size.
- Rendering text in an image or canvas.
How do you test the finished app in the browser?
Linting and unit tests check the source. The browser shows what users get, including content from third-party scripts and CMS data. Test the live or staging app:
- Scan key routes with an automated tool.
- Use only the keyboard on each main flow: sign up, search, checkout, settings.
- After every route change, check where focus is and what a screen reader says.
- Test at 200% and 400% zoom and on a phone.
- Record issues with the WCAG criterion, then fix by severity.
See how to run a website accessibility audit.
Kerbwise audits the page you have open against WCAG 2.2 Level A and AA and ranks accessibility issues by severity, with the WCAG number, who is affected and how to fix each one. Because it runs in Chrome on the rendered page, it works for React and Next.js apps in development, on staging or in production. It does not replace testing with a keyboard and a screen reader, and it checks the page you have open, so audit each route or state you care about.
Try Kerbwise on a page you own
Try Kerbwise ($29 one-time) to run this audit locally and export a client-ready PDF report. Get it on the Chrome Web Store or read more on the Kerbwise page.
Frequently asked questions
Is React accessible by default?
React renders whatever HTML you write, so accessibility depends on your code. Semantic elements, labels, focus management and announcements are your job, in React as in any other framework.
Does Next.js handle accessibility for me?
Partly. Next.js documents a route announcer that announces client-side page changes, using the page title, then the first h1, then the URL. It also documents ESLint accessibility rules. It does not fix labels, focus, contrast or custom components, so you still have to test.
How do I manage focus after a route change in React?
Update the document title, then move focus to the new page's main heading or main region, using a ref and tabIndex={-1}. Skip it on first load, and test with a screen reader to check the result.
Which React component library is the most accessible?
Libraries built on accessibility-focused primitives, such as Radix UI and React Aria, are a strong starting point, but none guarantees an accessible result. Your styling, labels and overrides still matter, so test the components you ship.
Can automated tests catch all React accessibility issues?
No. Linting and axe-based tests catch many structural problems, but not whether focus moves sensibly, whether announcements make sense or whether a flow can be completed with a keyboard or screen reader.