# Accessibility

Goal: a screen reader and a keyboard user learn what a client navigation or an update inside a page did. A navigation does not reload the document, so nothing moves focus or speaks unless the app says so.

1. Keep the defaults. After a client navigation Hamur moves focus, without scrolling, to the `#hash` target, an `[autofocus]` element, or the first `h1`, and announces the page's title in a live region. Both are keys of the config, and `false` or `"none"` turns them off:

````ts [recipes/accessibility-config.ts]
import { defineConfig } from "hamur"

export default defineConfig({
  framework: "react",
  app: {
    navigation: { focus: "heading" },
    routeAnnouncer: { politeness: "polite" },
  },
})
````

2. Give every page one `h1` and a title: the announcement and the focus read them.
3. Announce changes inside a page yourself. `useAnnouncer()` writes into two live regions that never change their `aria-live`: `polite(message)` for a saved form, `assertive(message)` for an error. Use `<Announcer />` once to place the regions:

````tsx [recipes/react/Accessibility.tsx]
import { useAnnouncer } from "@hamur/adapter-react"
import { useState } from "react"

export default function Settings() {
  const { polite, assertive } = useAnnouncer()
  const [name, setName] = useState("")
  const save = async () => {
    const response = await fetch("/api/profile", {
      method: "POST",
      body: JSON.stringify({ name }),
      headers: { "content-type": "application/json" },
    })
    if (response.ok) polite("Profile saved")
    else assertive("Profile not saved")
  }
  return (
    <form onSubmit={(event) => (event.preventDefault(), void save())}>
      <label htmlFor="name">Name</label>
      <input id="name" value={name} onChange={(event) => setName(event.target.value)} autoComplete="name" />
      <button type="submit">Save</button>
    </form>
  )
}
````

4. Check what you built. The Audit tab of the [devtools](/devtools) lists findings on the current page, such as a missing `lang`, an image without `alt`, a button without a name, a duplicate `id` or a skipped heading level, and highlights each element. It does not replace trying the page with a keyboard and a screen reader.

See also: [Navigation](/api-reference/navigation-details#focus-after-a-navigation), [Configuration](/configuration), [Adapters](/adapters).
