#Astro Form

1 messages · Page 1 of 1 (latest)

cursive tiger
#

does astro have any helpers to make a form enhance to be async

crude raptorBOT
#

Hi @cursive tiger. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, Astro allows you to enhance a form to be async by intercepting the form submission using JavaScript. To do this, you'll need a project with SSR (output: 'server') enabled and a UI Framework integration installed. Here's a brief overview of the process:

  1. Create an HTML form in your Astro component.
  2. Add a script tag to your Astro component to handle form submission.
  3. Prevent the default form submission behavior and send the form data to an API endpoint using JavaScript.

For more details, refer to the Build Forms With API Routes (https://docs.astro.build/en/recipes/build-forms-api) recipe in the Astro documentation.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Astro Documentation

Learn how to use JavaScript to send form submissions to an API Route