Skip to content

Commit

Permalink
Add docs on Astro.clientAddress (#1039)
Browse files Browse the repository at this point in the history
* Add docs on Astro.clientAddress

* Add the Since tag for Astro.clientAddress
  • Loading branch information
matthewp authored Jul 20, 2022
1 parent e80b127 commit c00714d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/pages/en/reference/api-reference.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
setup: import Since from '~/components/Since.astro';
layout: ~/layouts/MainLayout.astro
title: API Reference
i18nReady: true
Expand Down Expand Up @@ -135,6 +136,20 @@ const path = Astro.canonicalURL.pathname;
<h1>Welcome to {path}</h1>
```

### `Astro.clientAddress`

<Since v="1.0.0-rc" />

Specifies the [IP address](https://en.wikipedia.org/wiki/IP_address) of the request. This property is only available when building for SSR (server-side rendering) and should not be used for static sites.

```astro
---
const ip = Astro.clientAddress;
---
<div>Your IP address is: <span class="address">{ ip }</span></div>
```

### `Astro.site`

`Astro.site` returns a `URL` made from `site` in your Astro config. If undefined, this will return a URL generated from `localhost`.
Expand Down

0 comments on commit c00714d

Please sign in to comment.