diff --git a/src/content/docs/en/reference/api-reference.mdx b/src/content/docs/en/reference/api-reference.mdx index 231c7b600f318..5b60008487780 100644 --- a/src/content/docs/en/reference/api-reference.mdx +++ b/src/content/docs/en/reference/api-reference.mdx @@ -369,9 +369,13 @@ If true, the cookie is only set on https sites. Allows customizing how the cookie is serialized. ### `Astro.redirect()` -`Astro.redirect()` allows you to redirect to another page. + +Allows you to redirect to another page, and optionally provide an [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) as a second parameter. + A page (and not a child component) must `return` the result of `Astro.redirect()` for the redirect to occur. +The following example redirects a user to a login page, using the default HTTP response status code 302: + ```astro title="src/pages/account.astro" {8} --- import { isLoggedIn } from '../utils';