Core Concepts

Redirects

Redirecting users after form submission

After a successful form submission, you can redirect users to a custom "thank you" page or any other URL. This provides better user experience and allows you to display confirmation messages, next steps, or additional content.

Basic Redirect

To redirect users after a successful submission, add a hidden redirectTo field to your form:

HTML

How It Works

When the form is submitted successfully, Static Forms will redirect the browser to the URL specified in the redirectTo field. This only happens on successful submissions (HTTP 200). If there's an error, the user stays on the form page.

Redirect Behavior

Understanding when redirects occur:

Redirects Happen When:

  • Form submission is successful (200 OK)
  • All validations pass
  • Email is sent successfully

No Redirect When:

  • API key is invalid (401)
  • Rate limit exceeded (429)
  • Validation fails (400)
  • Spam detected (400)
  • Server error (500)

Relative vs Absolute URLs

You can use both relative and absolute URLs for redirects:

Absolute URL (Recommended)

HTML

Relative URL

HTML

Relative URLs

Relative URLs work, but absolute URLs are recommended for better reliability, especially if your form might be embedded in different contexts or domains.

Dynamic Redirects

You can set the redirect URL dynamically using JavaScript:

HTML

Passing Data to Redirect Page

You can pass form data to your redirect page using URL parameters. However, Static Forms doesn't automatically append form data to the redirect URL. You'll need to handle this with JavaScript:

HTML

Reading Parameters on Thank You Page

On your thank you page, you can read the URL parameters:

HTML

AJAX Submissions and Redirects

When using AJAX to submit forms, you need to handle redirects manually:

JavaScript

Error Handling

By default, if a form submission fails, the user stays on the form page. You can enhance error handling:

Error Redirect (Custom Implementation)

Static Forms doesn't support automatic error redirects, but you can implement custom error handling:

HTML

Best Practices

Always Use Absolute URLs

Absolute URLs (starting with https://) are more reliable and work in all contexts.

Create a Thank You Page

Design a dedicated thank you page that confirms the submission and sets expectations for follow-up.

Handle AJAX Submissions

If using AJAX, manually handle redirects in your JavaScript code after receiving a successful response.

Provide Clear Feedback

Your thank you page should clearly communicate that the submission was successful and what happens next.

Example Thank You Page

Here's a simple example of a thank you page:

HTML