> ## Documentation Index
> Fetch the complete documentation index at: https://acme-c84a37e5.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Type-safe error handling for TypeScript with retry logic and concurrency control

<img className="block dark:hidden" src="https://mintcdn.com/acme-c84a37e5/F2BjdC4pEAaDdoiY/logo/light.svg?fit=max&auto=format&n=F2BjdC4pEAaDdoiY&q=85&s=18e71ec927d036edfd6ec1593b26c259" alt="Logo Light" width="200" height="50" data-path="logo/light.svg" />

<img className="hidden dark:block" src="https://mintcdn.com/acme-c84a37e5/F2BjdC4pEAaDdoiY/logo/dark.svg?fit=max&auto=format&n=F2BjdC4pEAaDdoiY&q=85&s=0ceeb50908b3b6e5841c41c2c1a689bf" alt="Logo Dark" width="200" height="50" data-path="logo/dark.svg" />

## Welcome to Tryo

A modern, type-safe error handling library that makes async operations predictable and resilient.

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Get up and running in less than 5 minutes
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/tryo">
    Explore the complete API documentation
  </Card>

  <Card title="Examples" icon="lightbulb" href="/examples/react">
    Real-world examples and patterns
  </Card>

  <Card title="GitHub" icon="github" href="https://github.com/tu-usuario/tu-repo">
    View source code and contribute
  </Card>
</CardGroup>

## Features

<AccordionGroup>
  <Accordion icon="check" title="Type-Safe Error Handling">
    No more `try-catch` blocks. Get discriminated unions with full TypeScript support.

    ```typescript theme={null}
    const result = await runner.run(() => apiCall());
    if (result.ok) {
      // TypeScript knows data is available
      console.log(result.data);
    }
    ```
  </Accordion>

  <Accordion icon="arrows-rotate" title="Smart Retry Logic">
    Built-in exponential backoff with jitter to prevent thundering herd.

    ```typescript theme={null}
    await runner.run(() => unstableApi(), {
      retry: {
        maxRetries: 3,
        strategy: RetryStrategies.exponential(1000),
      }
    });
    ```
  </Accordion>

  <Accordion icon="layer-group" title="Concurrency Control">
    Run multiple operations with controlled parallelism.

    ```typescript theme={null}
    await runner.all(tasks, { 
      concurrency: 5 
    });
    ```
  </Accordion>

  <Accordion icon="ban" title="Abort Handling">
    First-class support for `AbortController` and graceful cancellation.

    ```typescript theme={null}
    await runner.run(() => fetch('/api', { signal }), {
      ignoreAbort: true
    });
    ```
  </Accordion>
</AccordionGroup>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install tryo
  ```

  ```bash pnpm theme={null}
  pnpm add tryo
  ```

  ```bash yarn theme={null}
  yarn add tryo
  ```
</CodeGroup>

## Quick Example

```typescript theme={null}
import tryo from "tryo";

const runner = tryo();

const result = await runner.run(() => fetch("https://api.example.com/users"), {
  retry: {
    maxRetries: 3,
    strategy: RetryStrategies.fixed(1000),
  },
  hooks: {
    onError: (error) => console.error(error),
  }
});

if (result.ok) {
  const users = await result.data.json();
  console.log(users);
}
```

<Note>
  **Pro tip:** Use `tryo()` once and reuse it across your app for consistent
  error handling.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Core Concepts" icon="book" href="/concepts/result-type">
    Learn about Result types and error normalization
  </Card>

  <Card title="React Integration" icon="react" href="/examples/react">
    See how to use it with React hooks
  </Card>
</CardGroup>
