Skip to content
On this page

onAbort since v0.12

Binds a passed function to the aborting of the Query or Mutation.

import { onAbort, createQuery } from '@farfetched/core';

const myQuery = createQuery({
  async handler() {
    const abortController = new AbortController();

    onAbort(() => {

    const response = await fetch('', {
      signal: abortController.signal,

    return response.text();


  1. onAbort can only be called inside the handler of a Query or Mutation. Calling it outside a handler will throw an error.
  2. onAbort can only be called once per handler. Calling it multiple times will throw an error.
  3. onAbort can only be called before asynchronous operations are started. Calling it after asynchronous operations have started will throw an error.

Released under the MIT License.