Spoosh
Plugins

Retry

Automatic retry on failure

The retry plugin automatically retries failed requests with configurable attempts and delay.

Installation

npm install @spoosh/plugin-retry

Usage

import { retryPlugin } from "@spoosh/plugin-retry";

const plugins = [
  retryPlugin({ retries: 3, retryDelay: 1000 }), // 3 retries with 1 second delay
];

Per-Request Override

// More retries for critical requests
useRead((api) => api.important.$get(), { retries: 5, retryDelay: 2000 });

// Disable retries for specific requests
useRead((api) => api.health.$get(), { retries: false });

Options

Plugin Config

OptionTypeDefaultDescription
retriesnumber | false3Number of retry attempts. Set to false to disable.
retryDelaynumber1000Delay between retries in milliseconds

Per-Request Options

OptionTypeDescription
retriesnumber | falseOverride retry attempts for this request
retryDelaynumberOverride retry delay for this request

On this page