01 / Build
Prepare the local package
npm ci
npm run build:dist
Framework-free TypeScript · Browser package
Normalize unpredictable API payloads, connect messages to real form controls, and move focus toward a useful recovery point without taking over submission.
Response route
a11y-server-error-bridgetextContent, never server HTMLLive demo · Basic recovery
Activate the simulated response. Focus moves to the form error region, the email field receives linked error text, and editing the email clears only that field error.
Start with source
The package is not published to npm yet. Build the repository locally, then import the generated ESM and stylesheet.
01 / Build
npm ci
npm run build:dist
02 / Markup
<link rel="stylesheet" href="./dist/styles.css">
<form data-a11y-server-error-bridge>
<div data-a11y-server-error-bridge-form-errors></div>
<label for="email">Email</label>
<input id="email" name="email">
</form>
03 / JavaScript
import { createServerErrorBridge } from "./dist/index.js";
const bridge = createServerErrorBridge(form);
bridge.applyErrors({
fields: { email: "Already used" },
form: ["Please review the form"]
});
Verified API
Options are passed to createServerErrorBridge(form, options). Defaults shown here come from the package source.
| Option | Default | Purpose |
|---|---|---|
focusOnApply | "auto" | Chooses summary, form error, or first-invalid recovery. |
unknownFieldStrategy | "form" | Promotes, retains, or ignores messages without a matched control. |
messageMode | "first" | Shows the first field message or every message. |
clearOnInput | true | Clears the edited field's owned error state. |
clearOnChange | true | Supports controls whose value commits on change. |
useAriaErrorMessage | true | Adds aria-errormessage alongside aria-describedby. |
fieldAliases | {} | Maps backend field keys to selectors, elements, or resolver functions. |
addons | [] | Hands work to optional integration contracts. |
applyErrors()clearErrors()clearField()destroy()Events bubble from the form and use the a11y-server-error-bridge: prefix.
init · normalize · apply · field-resolved · field-unresolved · integration-conflict · focus · clear · error · destroy
Accessibility behavior
The bridge augments the form you provide. It does not certify the final application or replace testing with real responses and assistive technology.
Labels, inputs, headings, lists, and regions remain application markup.
Resolved controls receive aria-invalid, descriptions, and optional error-message references.
Explicit error application can focus a summary, form message, or first invalid field.
Clear and destroy restore the attributes the bridge found before rendering.
The bridge adds no custom shortcut layer. Use standard Tab, Shift + Tab, Enter, and Space behavior supplied by native form controls.
Submission, retries, authentication, client validation, translations, and live-region policy remain application responsibilities. Pass existing peer instances when the first rejected response must be handled synchronously.
Override --a11y-server-error-bridge-error-color, --a11y-server-error-bridge-background, --a11y-server-error-bridge-gap, and the documented bridge classes.
Scenario library
Every example uses local payloads and built package files. No request leaves your browser.
Nested field aliases, multiple messages, unknown fields, and correction.
01 · BasicSmallest useful setupOne field error, one form error, and edit-to-clear behavior.
02 · AdaptersCompare payload shapesEnvelopes, flat objects, arrays, and Problem Details.
03 · WorkflowFollow a rejected submitPending, error recovery, and a successful retry.
04 · AddonValidator handoffGive normalized messages to an existing validator instance.
05 · AddonSummary handoffSynchronize an external summary with inline output and focus.
06 · AddonAsync retry handoffConnect rejection text to pending, retry, and success states.
07 · AddonRespect active conditionsExclude inactive fields and recover focus only within the active path.