Redirect URI Input

Catches OAuth redirect URIs that are close to but not exactly the registered one, plus unsafe ones like localhost in production or wildcards.

StopsOAuth redirect_uri_mismatch error

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/redirect-uri-input.json

The files land in your project. They're yours to edit.

Usage

redirect-uri-input-usage.tsx
import { RedirectUriInput } from "@/components/ui/redirect-uri-input"

<RedirectUriInput value={uri} onValueChange={setUri} registered={registered} production />

What it catches

  • Near-misses against registered URIs: trailing slash, http vs https, case, www, port
  • Side-by-side highlight of the differing characters, with a one-tap swap
  • localhost or loopback in a production client
  • Wildcards, a #fragment, default :443 port, empty ? and stray whitespace
  • Short custom schemes for native apps

Props

RedirectUriInput props
PropTypeDefault
value

Controlled URI.

string—
defaultValue

Initial URI when uncontrolled.

string""
onValueChange

Called on every change and fix.

(value: string) => void—
registered

URIs registered with the provider. Turns on the exact-match check with a near-miss diff.

string[][]
production

A production client: localhost is an error. Plain http to any other host is always an error (RFC 9700 §2.6).

booleanfalse
native

A native or desktop app (RFC 8252): loopback ports may vary and custom schemes are expected.

booleanfalse
onIssuesChange

Called with the current issues after each check, so a form can block saving on errors.

(issues: RedirectIssue[]) => void—
delay

Pause in ms before the check runs while typing. Leaving the field or a fix runs it at once.

number500
messages

Override any visible or announced text.

Partial<RedirectUriMessages>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label> tied to the input; aria-invalid on errors
  • Status summary in a polite live region linked by aria-describedby
  • After a one-tap fix, focus returns to the input
  • Match state shown with icon and text

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: The authorization server must compare redirect_uri by exact string match against the registered list.

  • Checks the string only; it cannot see what your provider actually has registered unless you pass it
  • Providers differ (some allow loopback port variation for native apps); follow your provider's rules
  • Not a substitute for server-side exact matching

Rules

Rules last verified:

Confirmed: RFC 9700 requires exact string matching of redirect URIs, except variable port numbers for localhost redirect URIs of native apps. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

OAuth redirect_uri_mismatch error

Also known as

oauth · redirect uri · callback url · google sign in · nextauth · auth0 · openid · sso

Field type

Dependencies

Pairs well with