diff --git a/src/content/docs/en/recipes/build-forms-api.mdx b/src/content/docs/en/recipes/build-forms-api.mdx new file mode 100644 index 0000000000000..d2cb25fc7715d --- /dev/null +++ b/src/content/docs/en/recipes/build-forms-api.mdx @@ -0,0 +1,401 @@ +--- +title: Build Forms With API Routes +description: Learn how to use JavaScript to send form submissions to an API Route +i18nReady: false +type: recipe +--- +import UIFrameworkTabs from "~/components/tabs/UIFrameworkTabs.astro"; +import PackageManagerTabs from "~/components/tabs/PackageManagerTabs.astro" + +An HTML form causes the browser to refresh the page or navigate to a new one. To send form data to an API endpoint instead, you must intercept the form submission using JavaScript. + +This recipe shows you how to send form data to an API endpoint and handle that data. + +## Prerequisites +- A project with [SSR](/en/guides/server-side-rendering/) (`output: 'server'`) enabled +- A [UI Framework integration](/en/core-concepts/framework-components/) installed + +## Recipe + +1. Create a form component using your UI framework. Each input should have a `name` attribute that describes the value of that input. + + Be sure to include a `