# links

## Table of Contents

- [Options](#options)
- [Examples](#examples)

---

Sweeps every `a` element and returns each `href` as an absolute, deduped URL:

```js
constlinks=awaitmicrolink.links('https://example.com')
```

Relative hrefs are resolved against the page URL, and values that don't parse as a URL — `mailto:`, `javascript:`, empty anchors — are dropped by the `'url'` [type](https://microlink.io/docs/sdk/methods/extract/type).

## Options

Override the default rule of `selectorAll: 'a'`, `attr: 'href'`, and `type: 'url'` with [selectorAll](https://microlink.io/docs/sdk/methods/extract/selectorAll), [selector](https://microlink.io/docs/sdk/methods/extract/selector), [attr](https://microlink.io/docs/sdk/methods/extract/attr), or [type](https://microlink.io/docs/sdk/methods/extract/type).

## Examples

Only the navigation links:

```js
constlinks=awaitmicrolink.links('https://example.com',{

selectorAll:'nav a'

})
```

Links on a client-side rendered page:

```js
constlinks=awaitmicrolink.links('https://app.example.com',{

prerender:true,

waitForSelector:'main a'

})
```

External links only, filtered on your side:

```js
const{hostname}=newURL('https://example.com')

constlinks=awaitmicrolink.links('https://example.com')

constexternal=links.filter(link=>newURL(link).hostname!==hostname)
```

For each link's text alongside its URL, write a nested rule with [extract](https://microlink.io/docs/sdk/methods/extract).