1
Collect the form data
Read values from the form using
FormData.2
Submit and redirect
For server-driven routing, submit from a backend endpoint and redirect from there.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Send users to different pages based on their submission.
Collect the form data
FormData.Submit and redirect
const formData = new FormData(formElement);
const plan = String(formData.get('plan') || 'free');
const response = await fetch('https://formbase.dev/s/YOUR_FORM_ID', {
method: 'POST',
body: formData,
redirect: 'manual',
});
if (response.status === 303 || response.ok) {
if (plan === 'pro') {
window.location.href = '/thanks-pro';
} else {
window.location.href = '/thanks-free';
}
}