Skip to content

Astro

Add Astro’s React integration if your project doesn’t have it, then the package:

Terminal window
npx astro add react
Terminal window
npm install @seaforms/react

There are two ways, and both put the form in your page’s HTML. Pick by who changes it:

  • From the form’s file if you change the form yourself. A pull shows up in your diff, and a build never depends on Seaforms answering.
  • Fetched at build if a client or colleague changes it. They publish in the app and your next build has it, with no file to pull or commit.

Hand this to your coding agent

Read https://developer.seaforms.io/llms-full.txt.
Install @seaforms/react in this Astro project. Run npx seaforms login (I'll approve it in my browser), then npx seaforms pull to save my published forms in src/forms with their types.
Then add the contact form to src/pages/contact.astro with the Form component and client:load.
Use only the components, functions and commands that file lists, and don't edit the .seaforms.json files.

Save your published forms into the project with npx seaforms pull, then import one:

  • Directorysrc
    • Directoryforms
      • contact.seaforms.json from npx seaforms pull
      • contact.seaforms.d.ts its types
    • Directorypages
      • contact.astro the page
  • astro.config.mjs
  • seaforms.json which site this project is
src/pages/contact.astro
---
import { Form } from "@seaforms/react";
import contact from "../forms/contact.seaforms.json";
---
<h1>Get in touch</h1>
<Form schema={contact} client:load />

Astro renders the form into the page’s HTML whatever you choose. The directive decides when it wakes up.

Directive When to use it
client:load The default. It wakes as the page loads. Use it on every page of a form that offers Save and finish later: the emailed link’s key leaves the address bar only once the script runs.
client:visible A form further down the page. It wakes when it scrolls into view.
none, with static A page that loads no script. Every step shows on one page, with one Send at the end, and the thank-you comes from our server. See Without JavaScript.
src/pages/contact.astro
<Form schema={contact} client:visible />
<Form schema={contact} static />

Import it once, in a layout:

src/layouts/Base.astro
---
import "@seaforms/react/theme.css";
---

See Styling for its variables, or your own classes instead.

What this page promises (in the HTML, works before JavaScript, no shift, keyboard and screen readers) is checked by our tests in real Chrome on an Astro site, on all 16 templates.

Was this helpful?

Your answer goes straight to the person who wrote it.

Thanks. We read every note and update the article.

Thanks, that helps us keep these useful.

ChatGPT is a trademark of OpenAI, and Claude and Claude Code are trademarks of Anthropic. Other product names and logos belong to their owners. None of them makes or endorses Seaforms. Trademarks