---
title: "crawl"
description: "Walks an app by dispatching requests straight into its router, yielding each response as it arrives. No socket, no server, no browser: the router's `fetch` is the whole transport, so this runs anywhere the app itself runs."
url: "https://pitlane.tools/package/crawler/function/crawl"
---

# crawl

```ts
import { crawl } from "@pitlane/crawler";
```

```ts
function crawl(router, options?): AsyncIterableIterator<CrawlResult>;
```

Walks an app by dispatching requests straight into its router, yielding each response as it arrives. No socket, no server, no browser: the router's `fetch` is the whole transport, so this runs anywhere the app itself runs.

Yields in completion order. Every path is fetched at most once. A redirect yields nothing and reports through [CrawlOptions.onRedirect](https://pitlane.tools/package/crawler/interface/CrawlOptions.md#onredirect); any other non-2xx response aborts the crawl.

## Parameters

### router

[`CrawlTarget`](https://pitlane.tools/package/crawler/interface/CrawlTarget.md)

The router to crawl.

### options?

[`CrawlOptions`](https://pitlane.tools/package/crawler/interface/CrawlOptions.md) = `{}`

Crawl options.

## Returns

`AsyncIterableIterator`\<[`CrawlResult`](https://pitlane.tools/package/crawler/interface/CrawlResult.md)>

An async iterator of results, one per fetched path.

## See

- [Crawler guide](https://pitlane.tools/guides/crawler.md)
- [Prerendering guide, without a build](https://pitlane.tools/guides/prerendering-no-build.md)
