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:
How It Works
When the form is submitted successfully and redirectTo is provided, Static Forms will redirect the browser to the specified URL using an HTTP 303 response. 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 and
redirectTois provided (303 redirect) - 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
Redirects must use absolute URLs with http or https:
Absolute URL (Required)
Invalid URLs
Relative URLs are not accepted. Provide a full URL that starts with http:// or https://.
Dynamic Redirects
You can set the redirect URL dynamically using JavaScript:
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:
Reading Parameters on Thank You Page
On your thank you page, you can read the URL parameters:
AJAX Submissions and Redirects
When using AJAX to submit forms, you need to handle redirects manually:
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:
Best Practices
Always Use Absolute URLs
Absolute URLs (starting with http:// or https://) are required 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: