Formbase stores every submission, but sometimes you want the values immediately after submit to personalize the next screen. You can do this in two ways:
- Use the existing form data in the browser
- Submit from the server and use the JSON response
Client-side data (fastest)
Use the values you already have in the browser and redirect with state or query params.const formData = new FormData(formElement);
const response = await fetch('https://formbase.dev/s/YOUR_FORM_ID', {
method: 'POST',
body: formData,
redirect: 'manual',
});
if (response.status === 303 || response.ok) {
sessionStorage.setItem('lastSubmission', JSON.stringify({
email: formData.get('email'),
}));
window.location.href = '/thanks';
}
On your thank-you page, read sessionStorage and render a personalized message. Server-side data (structured)
Submit from your server and return the JSON payload to your client.const response = await fetch('https://formbase.dev/s/YOUR_FORM_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]' }),
});
const result = await response.json();
// result.data contains the submitted object
This is the best option when you need a reliable JSON response.
Browser requests receive a redirect instead of JSON. Use a server action or API route if you need the response body.