# Redirects and thank-you pages

> After a visitor sends the form, they land on your page, ours, or stay where they are.

Last updated 2026-11-14. Web version: https://wrenform.com/docs/redirects

```html
<input type="hidden" name="_redirect" value="https://example.com/thanks">
```

## Where the visitor lands

For a normal form post, we answer with a `303` redirect. We pick the first of these that applies:

1. The `_redirect` field, if it's allowed (below).
2. **Redirect to** in the form's settings (the success URL).
3. Our hosted thank-you page.

Spam gets the same redirect, so bots can't tell they were caught.

## Your own thank-you page

The simplest way: set **Redirect to** in the form's settings, for example `https://example.com/thanks`. It must be an `https://` address (`http://localhost` is allowed for testing). Nothing changes in your HTML.

## The `_redirect` field

Use it when one form serves several pages, or each page needs its own thank-you page. We follow it only when:

- it's an absolute `http://` or `https://` URL; and
- its origin is in the form's **Allowed origins**, or, while that list is empty, it's the same origin as the page that posted.

Otherwise we ignore it and fall back to **Redirect to**, then our page. We are never an open redirect.

## Our hosted thank-you page

It says "Thanks! Your message was sent." and has a **Back** link to the page the visitor came from. On the free plan it also shows a small "Form handled by Wrenform" link. It isn't indexed by search engines.

Errors have a hosted page too: it shows the HTTP status, a plain message and a **Back** link. Error codes are listed in [errors](/docs/errors).

## Stay on the page

To show the result without leaving the page, send the form with JavaScript and ask for JSON. Redirect settings don't apply to JSON requests.

```js
const form = document.querySelector("#contact");
form.addEventListener("submit", async (event) => {
  event.preventDefault();
  const res = await fetch(form.action, {
    method: "POST",
    headers: { Accept: "application/json" },
    body: new FormData(form),
  });
  const result = await res.json();
  if (result.ok) {
    form.reset();
    form.querySelector("[role=status]").textContent = "Thanks, your message was sent.";
  } else {
    form.querySelector("[role=status]").textContent = result.error.message;
  }
});
```

A request gets JSON when its body is `application/json`, or when its `Accept` header lists `application/json` before `text/html`. Success is `{ "ok": true, "id": "…" }`. An error is `{ "ok": false, "error": { "code", "message", "docs" } }` with the matching HTTP status.

Framework versions: [Astro](/docs/frameworks/astro#stay-on-the-page-optional), [Next.js](/docs/frameworks/nextjs).

## Test it

Send the form and check the address bar: you should be on the page you chose. If you land on our thank-you page instead, your `_redirect` was ignored; see below.

## Common problems

- **`_redirect` is ignored.** Its origin isn't in **Allowed origins**. Add the origin (for example `https://example.com`), or use **Redirect to** instead.
- **`_redirect` works on the live site but not locally.** Locally, the page's origin is `http://localhost:…`, which doesn't match the redirect's origin.
- **The browser blocks the redirect.** A strict Content-Security-Policy `form-action` must list your own origin as well as ours. See the [HTML guide](/docs/frameworks/html#strict-content-security-policy-sites).
- **Relative URLs don't work.** Use a full URL: `https://example.com/thanks`, not `/thanks`.

## Next steps

- [Fields](/docs/fields): every reserved field.
- [Spam](/docs/spam): how submissions are judged.
