> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prequel.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Deleting destinations

> Build functionality for your users to delete their destinations.

<Steps>
  <Step title="Creating a deleteDestination function">
    In your frontend, call the `useDeleteDestination` hook to generate a function that fetches a scoped auth token and uses it to delete the destination scoped by the token. Use one of the `fetchToken` functions you wrote in [Building an "Add Destination" connection form](/export/sdks/react/tutorials/building-an-add-destination-connection-form) here to create one.

    ```tsx title="Create deleteDestination" icon="react" expandable theme={null}
    const deleteDestination = useDeleteDestination(
      fetchToken,  				// fetchToken implementation, takes an ExistingDestination
      "app.example.co", 	// the origin of your React app (used to allow CORS),
      PREQUEL_HOST 				// Optional (default api.prequel.co): the host url of your Prequel API
    );
    ```
  </Step>

  <Step title="Using deleteDestination">
    Use `deleteDestination` created in Step 1 to delete the given destination.

    ```tsx title="DestinationView" icon="react" expandable theme={null}
    const DestinationView = () => {
      // Deletion function creation elided

    	// Async function deletes destination using Prequel API
    	async function onDelete(existing: ExistingDestination) => {
      	const response = await deleteDestination(existing);
    		if (response.status === "success") {
    	  	// Handle success
      	} else {
    	  	// Handle failure
      	}
    	};

      return (
    		<button type="button" onClick={onDelete}>Delete destination</button>
      );
    }
    ```
  </Step>
</Steps>
