a11ied

Source on GitHub

a11ied
Menu

Automate

Check screen reader support in code

@a11ied/compat answers the question the compatibility tables answer, in code. Give it your Browserslist query and the ARIA and HTML features you use. It tells you which screen readers in those browsers fail each feature. Use it in a lint rule, an editor extension, or a build step.

Install

npm install --save-dev @a11ied/compat

The results ship inside the package, so a check reads no network and gives the same answer every time. They are the same results the screen reader compatibility tables show: W3C ARIA-AT reports, and test cases a11ied ran.

Check the features you use

checkCompatibility takes a Browserslist query and a list of features. It returns one diagnostic for each way a feature fails in the browsers you named.

import { checkCompatibility } from '@a11ied/compat';

const report = checkCompatibility({
   browserslist: 'last 2 safari versions',
   usages: [
      'aria-pressed',
      'aria-posinset',
      {
         feature: 'aria-invalid',
         element: '<input aria-invalid="true">',
         location: { file: 'src/signup.tsx', line: 12, column: 8 },
      },
   ],
});

for (const diagnostic of report.diagnostics) {
   const { file, line } = diagnostic.location ?? {};
   const where = file ? `  ${file}:${String(line)}` : '';
   console.log(`${diagnostic.severity}  ${diagnostic.code}${where}`);
   console.log(`   ${diagnostic.message}`);
}

console.log(`${report.summary.errors} errors, ${report.summary.warnings} warnings`);
process.exitCode = report.summary.hasErrors ? 1 : 0;
error  a11ied/must-failure
   aria:aria-pressed fails RFC 2119 MUST requirements in VoiceOver for macOS 15.0 + Safari 18.6 (macOS 15.0) (+1 more).
error  a11ied/severe-side-effect
   aria:aria-pressed causes SEVERE screen reader side effects in VoiceOver for macOS 15.0 + Safari 18.6 (macOS 15.0) (+1 more).
warning  a11ied/should-failure
   aria:aria-posinset fails RFC 2119 SHOULD requirements in VoiceOver for macOS 15.0 + Safari 26 (macOS 15.0) (+1 more).
error  a11ied/must-failure  src/signup.tsx:12
   aria:aria-invalid fails RFC 2119 MUST requirements in VoiceOver for macOS 26 + Safari 26.2 (macOS 26) (+1 more).
3 errors, 1 warnings

Each message names the first screen reader, browser, and operating system that fails, and counts the rest. The report has four parts.

diagnostics
The problems found. This is the list a lint rule reports.
results
One entry per feature, with every matched test result. See check one feature.
targets
The browsers the query resolved to.
summary
Counts of errors, warnings, and notes. hasErrors is true when there is at least one error, and hasIssues when there is an error or a warning.

Ways to name a feature

A feature is a string, or an object when you want the diagnostic to carry a location.

'aria-pressed'
An ARIA attribute.
'role="alert"', 'aria:alert'
An ARIA role. Both forms mean the same feature.
'@checked', 'html:@checked'
An HTML attribute.
{ feature, element, location }
feature is one of the strings above. element is the markup, and location is a file, line, and column. Both are copied onto the diagnostic unchanged.

A name the data does not have gets the status unknown-feature. Pass reportUnknownFeatures: true to get a diagnostic for it. listSupportedFeatures() returns the 60 features the data covers.

Choose the browsers

browserslist
A query such as 'defaults' or 'last 2 versions', or a list of queries.
No browserslist
The check uses your project's Browserslist configuration, and defaults when it finds none.
path, env, config
Where Browserslist looks for that configuration, and which environment in it to use.

Browserslist names browsers, not screen readers, so each browser stands for the screen readers people use with it.

import { resolveBrowserslistTargets } from '@a11ied/compat';

const { targets } = resolveBrowserslistTargets({
   browserslist: 'last 1 chrome version, last 1 safari version, last 1 and_chr version',
});

for (const target of targets) {
   console.log(`${target.raw}: ${target.expectedScreenReaders.join(', ')}`);
}
and_chr 157: TalkBack
chrome 157: JAWS, NVDA, VoiceOver
safari 27.2: VoiceOver
Browserslist nameBrowserScreen readers checked
chromeChrome on a desktopJAWS, NVDA, VoiceOver
firefoxFirefox on a desktopNVDA, VoiceOver, JAWS
safariSafari on macOSVoiceOver
edgeEdge on WindowsJAWS, NVDA
and_chr, and_ffChrome and Firefox on AndroidTalkBack
androidAndroid WebViewTalkBack
ios_safSafari on iOSVoiceOver

These options narrow or widen what is checked.

screenReaders
Check only these, such as [ 'NVDA', 'JAWS' ].
versionMatching
'nearest', the default, uses the closest browser version that was tested. 'exact' uses a result only when the tested version matches the target.
includeWebViews
Count results recorded in a WebView. On by default.
includeVirtual
Count results from the simulated screen reader. Off by default, because it is not a screen reader anyone uses.

Read the diagnostics

MUST, SHOULD, and MAY are the priorities W3C ARIA-AT gives each check: what a screen reader is required to convey, what it is recommended to, and what it may.

CodeSeverityMeaning
a11ied/must-failureerrorA MUST check fails.
a11ied/severe-side-effecterrorThe screen reader did something the test did not expect, rated severe.
a11ied/should-failurewarningA SHOULD check fails.
a11ied/moderate-side-effectwarningThe screen reader did something the test did not expect, rated moderate.
a11ied/may-failureinfoA MAY check fails. Reported only with minPriority: 'MAY'.
a11ied/untested-targetinfoA browser and screen reader pair in your targets has no result. Reported only with reportUntested: true.
a11ied/unknown-featureinfoThe data does not have the feature. Reported only with reportUnknownFeatures: true.

minPriority sets how far down the list a check goes. The default, 'SHOULD', reports errors and warnings. 'MUST' reports errors only.

Each diagnostic has these fields.

code, severity, message
What a lint rule or an editor shows.
featureKey
The feature, such as aria:aria-pressed.
location, element
Copied from the usage you passed in.
specURL, docsPath
The feature in its specification, and its page in the compatibility tables. docsPath is a path under this site.
affectedEnvironments
Every failing screen reader, browser, and operating system, each with the checks that failed and any bug filed against the screen reader.

Check one feature

checkFeatureSupport returns the result for one feature without building diagnostics. Use it to show support in an editor hover or a documentation page.

import { checkFeatureSupport } from '@a11ied/compat';

const result = checkFeatureSupport('aria-pressed', {
   browserslist: 'last 1 chrome version, last 1 safari version',
});

console.log(result.status);

for (const match of result.matchedEnvironments) {
   const { environment, summary } = match;
   console.log(
      `${match.target.raw}: ${environment.screenReader} ${environment.screenReaderVersion}`,
      `with ${environment.browser} ${environment.browserVersion}`,
      `${match.outcome}, MUST ${summary.must.passed}/${summary.must.total}`,
      `(${match.matchPrecision})`,
   );
}

for (const gap of result.untestedTargets) {
   console.log(`${gap.target.raw}: ${gap.screenReader} is untested`);
}
unsupported
chrome 157: JAWS 2025.2508.120 with Chrome 143 pass, MUST 50/50 (nearest-older)
chrome 157: NVDA 2023.3.4 with Chrome 123.0.0 fail, MUST 47/50 (nearest-older)
safari 27.2: VoiceOver for macOS 15.0 with Safari 18.6 fail, MUST 28/36 (nearest-older)
chrome 157: VoiceOver is untested
status
supported, partial, unsupported, untested, or unknown-feature. One failing pair makes a feature unsupported.
matchedEnvironments
One entry for each target and screen reader that has a result: the tested environment, its outcome, the check counts, and the checks that failed.
matchPrecision
exact when the tested browser version is the target's. nearest-older or nearest-newer when the closest tested version was used.
untestedTargets
The target and screen reader pairs with no result, each with the reason.

Query the data

These functions read the results without a Browserslist query.

import {
   getFeature,
   getTestCaseOutcomes,
   listSupportedFeatures,
   queryEnvironments,
   queryTestCases,
} from '@a11ied/compat';

// Every tracked feature, or only the ones that match.
console.log(listSupportedFeatures().length);
console.log(listSupportedFeatures({ search: 'live' }).map((feature) => feature.key));

// One feature, with every environment it was tested in.
const alert = getFeature('role="alert"');
console.log(alert?.key, alert?.versionedEnvironments.length);

// The screen reader, browser, and operating system combinations with results.
const nvda = queryEnvironments({ screenReader: 'NVDA', status: 'tested' });
console.log(nvda.length);

// The test cases a11ied ran, and what a screen reader said in one of them.
const [ testCase ] = queryTestCases({ attribute: 'aria-live' });
const { runs } = getTestCaseOutcomes(testCase?.slug ?? '');
console.log(testCase?.slug, runs[0]?.outcome, runs[0]?.keyAnnouncement);
60
[ 'aria:aria-live' ]
aria:alert 14
23
aria-live-polite-update fail Save settings button is in the VoiceOver cursor | Save settings button
listSupportedFeatures(filter)
The features. Filter by type ('aria' or 'html') or search.
getFeature(name)
One feature with every environment it was tested in.
queryEnvironments(filter)
The tested combinations. Filter by screenReader, browser, os, status, or source.
queryTestCases(filter)
The test cases a11ied ran. Filter by attribute, category, tag, or search.
getTestCaseOutcomes(slug)
Each run of one test case, with its outcome and the transcript of what the screen reader said.
resolveBrowserslistTargets(options)
The browsers a query resolves to, and the screen readers each stands for.

The package exports the type of every value on this page, such as CompatibilityReport and CompatibilityDiagnostic.