Skip to content

toolmark-monorepo / @toolmark/inertia / InertiaVisitCallbacks

Interface: InertiaVisitCallbacks ​

Defined in: packages/inertia/src/visit-outcome.ts:10

Callbacks accepted by an Inertia visit (router.visit / useForm().submit), structurally covering both Inertia 2's callback names (onInvalid, onException) and Inertia 3's renamed ones (onHttpException, onNetworkError). Passing every name is harmless: whichever major is installed simply never calls the names it doesn't recognize.

Properties ​

onCancel? ​

optional onCancel?: () => void

Defined in: packages/inertia/src/visit-outcome.ts:24

The visit was cancelled.

Returns ​

void


onCancelToken? ​

optional onCancelToken?: (token) => void

Defined in: packages/inertia/src/visit-outcome.ts:26

Hands back a token whose cancel() aborts the in-flight visit.

Parameters ​

token ​
cancel ​

Returns ​

void


onError? ​

optional onError?: (errors) => void

Defined in: packages/inertia/src/visit-outcome.ts:14

The server responded with validation errors, keyed by field.

Parameters ​

errors ​

Record<string, string>

Returns ​

void


onException? ​

optional onException?: (error) => void

Defined in: packages/inertia/src/visit-outcome.ts:22

Inertia 2: an unexpected error occurred during the visit.

Parameters ​

error ​

unknown

Returns ​

void


onFinish? ​

optional onFinish?: (visit?) => void

Defined in: packages/inertia/src/visit-outcome.ts:28

The visit settled, one way or another.

Parameters ​

visit? ​
cancelled? ​

boolean

interrupted? ​

boolean

Returns ​

void


onHttpException? ​

optional onHttpException?: (response) => void

Defined in: packages/inertia/src/visit-outcome.ts:16

Inertia 3: the server responded outside the Inertia protocol (non-2xx / non-Inertia body).

Parameters ​

response ​

unknown

Returns ​

void


onInvalid? ​

optional onInvalid?: (response) => void

Defined in: packages/inertia/src/visit-outcome.ts:20

Inertia 2: the server response did not carry the X-Inertia header.

Parameters ​

response ​

unknown

Returns ​

void


onNetworkError? ​

optional onNetworkError?: (error) => void

Defined in: packages/inertia/src/visit-outcome.ts:18

Inertia 3: the request failed before a response arrived (offline, aborted transport, …).

Parameters ​

error ​

unknown

Returns ​

void


onSuccess? ​

optional onSuccess?: () => void

Defined in: packages/inertia/src/visit-outcome.ts:12

The visit succeeded.

Returns ​

void