# Async Patterns Guide

Use async operations with Marked.

## Enable Async Mode

```javascript { .api }
import { marked } from "marked";

marked.setOptions({ async: true });

const html = await marked.parse('# Async Markdown');
```

## Async Extensions

```javascript { .api }
import { marked } from "marked";

marked.use({
  async: true,
  async walkTokens(token) {
    if (token.type === 'link') {
      await validateUrl(token.href);
    }
  }
});

const html = await marked.parse(markdown, { async: true });
```

## When to Use Async

- Async `walkTokens` callbacks
- Async hooks (preprocess, postprocess)
- Extensions that perform async operations
- Fetching external data during parsing

## Performance Note

Async mode adds overhead. Only enable when needed.
