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

# Fetch Provider — Lightweight HTML Retrieval | GitResolve

> FetchProvider uses Node's built-in fetch to retrieve static HTML with zero dependencies — always available and ideal for GitHub profile pages.

`FetchProvider` is the lightest option in GitResolve's provider stack. It uses the `fetch` API that ships with Node.js 18+ to download page HTML over HTTP, without spinning up a browser process or requiring any additional packages. Because no external module needs to be imported, `isAvailable()` always returns `true` — making it the guaranteed fallback at the end of the auto-detection chain.

## When to use

* **Static portfolio sites** and plain HTML pages that don't rely on client-side rendering
* **GitHub and GitLab profile pages**, which are server-rendered and work perfectly with a standard HTTP request
* **Constrained environments** such as serverless functions, edge runtimes, or containers where installing a browser binary is not feasible
* **Fallback behaviour** when neither Puppeteer nor Browserless is available

<Warning>
  `FetchProvider` does **not** execute JavaScript. Single-page applications built with React, Vue, Next.js (client-only), or similar frameworks will return an empty shell or a loading spinner rather than real content. Use [PuppeteerProvider](/providers/puppeteer) or [BrowserlessProvider](/providers/browserless) for those sites.
</Warning>

## Installation

No installation is required. `FetchProvider` depends only on the native `fetch` global available in Node.js 18 and later. If you have already installed `@clyrisai/gitresolve`, you are ready to go.

## Usage

### Direct instantiation

```typescript theme={null}
import { FetchProvider } from '@clyrisai/gitresolve';

const provider = new FetchProvider();

const html = await provider.getPageContent('https://github.com/torvalds');
console.log(html.slice(0, 500));

await provider.cleanup(); // no-op, safe to call
```

### Via the factory

```typescript theme={null}
import { createProvider } from '@clyrisai/gitresolve';

const provider = await createProvider('fetch');
const html = await provider.getPageContent('https://gitlab.com/someone');
```

### CLI

To use `FetchProvider` from the command line, set the `BROWSER_PROVIDER` environment variable:

```bash theme={null}
BROWSER_PROVIDER=fetch gitresolve resolve resume.pdf
```

## Options

| Option      | Type     | Default | Description                                                                                         |
| ----------- | -------- | ------- | --------------------------------------------------------------------------------------------------- |
| `timeout`   | `number` | `15000` | Maximum milliseconds to wait for the response before aborting.                                      |
| `waitUntil` | —        | N/A     | Not applicable. `FetchProvider` returns the raw HTTP response body as soon as it is fully received. |

### Custom timeout example

```typescript theme={null}
const html = await provider.getPageContent('https://github.com/torvalds', {
  timeout: 5000, // abort after 5 seconds
});
```

## Behaviour details

| Property          | Value                                                           |
| ----------------- | --------------------------------------------------------------- |
| `name`            | `'fetch'`                                                       |
| `User-Agent`      | `Mozilla/5.0 (compatible; ClyrisBot/1.0)`                       |
| Redirect handling | `redirect: 'follow'` — follows all HTTP redirects automatically |
| Non-2xx responses | Throws `Error: Fetch failed with <status>: <statusText>`        |
| `isAvailable()`   | Always resolves to `true`                                       |
| `cleanup()`       | No-op — there are no resources to release                       |

<Info>
  The `Accept` header is set to `text/html,application/xhtml+xml` on every request, which encourages servers to return a browser-friendly HTML response rather than a JSON or API payload.
</Info>
