> ## Documentation Index
> Fetch the complete documentation index at: https://formbnb.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Redirects

> Redirect users after form submission

## Default Behavior

By default, after a successful submission, users see a simple "Thank you" page from FormBnB.

## Custom Redirect

### In Form Settings

Set a default redirect URL in your form settings. All submissions will redirect there.

### Using `_next` Field

Override the default with a hidden field:

```html theme={null}
<form action="https://api.formbnb.com/f/YOUR_ORG/YOUR_FORM" method="POST">
  <input type="hidden" name="_next" value="https://yoursite.com/thanks">
  
  <input type="email" name="email" required>
  <button type="submit">Subscribe</button>
</form>
```

### Dynamic Redirects

Use different redirects based on form context:

```html theme={null}
<!-- Contact page -->
<input type="hidden" name="_next" value="https://yoursite.com/contact/thanks">

<!-- Careers page -->
<input type="hidden" name="_next" value="https://yoursite.com/careers/thanks">
```

## Conditional Redirects

Use Form Rules to redirect based on submission data:

1. Go to form settings → Rules
2. Create a new rule
3. Set conditions (e.g., "department equals sales")
4. Add action: "Redirect to URL"
5. Enter the redirect URL

Example rules:

| Condition            | Redirect        |
| -------------------- | --------------- |
| department = sales   | /thanks/sales   |
| department = support | /thanks/support |
| Default              | /thanks         |

## AJAX Submissions

For AJAX submissions, handle the redirect in JavaScript:

```javascript theme={null}
const response = await fetch('https://api.formbnb.com/f/YOUR_ORG/YOUR_FORM', {
  method: 'POST',
  body: formData,
  headers: { 'Accept': 'application/json' }
});

if (response.ok) {
  window.location.href = '/thanks';
}
```

## Pass Submission Data

Include submission data in the redirect URL:

```html theme={null}
<input type="hidden" name="_next" value="https://yoursite.com/thanks?email={{ email }}">
```

<Warning>
  Be careful not to expose sensitive data in URLs. Use this only for non-sensitive fields.
</Warning>

## Same-Origin Redirects

For security, redirects must be to:

* The same domain as the form's allowed domains
* Or any HTTPS URL if no domain restrictions are set

## Troubleshooting

### Redirect not working?

1. Check the URL is valid and accessible
2. Ensure it's HTTPS (HTTP redirects may be blocked)
3. Check domain restrictions in form settings
4. For AJAX, make sure you're not setting `Accept: application/json` if you want automatic redirect
