The address (usually IP address) of the user.
Throws an error if used within a static site, or within a prerendered page.
Utility for getting and setting the values of cookies.
The current locale computed from the URL of the request. It matches the locales in i18n.locales, and returns undefined otherwise.
Returns a string with the current version of Astro.
Useful for using <meta name="generator" content={Astro.generator} /> or crediting Astro in a site footer.
Get an action result on the server when using a form POST.
Expects the action function as a parameter.
Returns a type-safe result with the action data when
a matching POST request is received
and undefined otherwise.
Example usage:
import { actions } from 'astro:actions';
const result = await Astro.getActionResult(actions.myAction);
Object accessed via Astro middleware
Parameters passed to a dynamic page generated using getStaticPaths
export async function getStaticPaths() { return [ { params: { id: '1' } }, ]; }
The current locale that is computed from the Accept-Language header of the browser (SSR Only).
The list of locales computed from the Accept-Language header of the browser, sorted by quality value (SSR Only).
List of props passed to this component
A common way to get specific props is through destructuring, ex:
const { name } = Astro.props
Redirect to another page (SSR Only)
Example usage:
if(!isLoggedIn) {
return Astro.redirect('/login');
}
Optional status: ValidRedirectStatusInformation about the current request. This is a standard Request object
For example, to get a URL object of the current URL, you can use:
const url = new URL(Astro.request.url);
Information about the outgoing response. This is a standard ResponseInit object
For example, to change the status code you can set a different status on this object:
Astro.response.status = 404;
Readonly headers: HeadersIt rewrites to another page. As opposed to redirects, the URL won't change, and Astro will render the HTML emitted by the rewritten URL passed as argument.
if (pageIsNotEnabled) {
return Astro.rewrite('/fallback-page')
}
The <Astro.self /> element allows a component to reference itself recursively.
Utility functions for modifying an Astro component’s slotted children
Asynchronously renders this slot and returns a string
A second parameter can be used to pass arguments to a slotted callback
Each item in the array will be passed as an argument that you can use like so:
```astro
<Component>
{(hello, world) => <div>{hello}, {world}!</div>}
</Component>
Optional args: any[]A full URL object of the request URL.
Equivalent to: new URL(Astro.request.url)
Fetch local files into your static site setup
Example usage:
const posts = await Astro.glob('../pages/post/*.md');
Astro global available in all contexts in .astro files
Astro reference