pickstack

SolidJS + TanStack Form

Type-safe forms with Zod or Yup validation. This page shows exactly what pickstack adds to a SolidJS project for TanStack Form: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework solid --modules tanstack-form --yes
Customize in the configurator

Packages it adds

PackageVersionType
@tanstack/solid-form^1.33.5runtime
zod^4.6.7runtime

New files

src/components/SignupForm.tsx
import { createForm } from "@tanstack/solid-form";
import { createSignal, Show } from "solid-js";
import { z } from "zod";

const schema = z.object({
  email: z.email("Enter a valid email address."),
});

export default function SignupForm() {
  const [joined, setJoined] = createSignal("");
  const form = createForm(() => ({
    defaultValues: { email: "" },
    validators: { onSubmit: schema },
    onSubmit: ({ value }) => setJoined(value.email),
  }));

  return (
    <Show
      when={!joined()}
      fallback={<p class="text">Thanks, {joined()} is on the list.</p>}
    >
      <form
        noValidate
        class="form"
        onSubmit={(event) => {
          event.preventDefault();
          void form.handleSubmit();
        }}
      >
        <form.Field name="email">
          {(field) => (
            <label class="field">
              Email
              <input
                type="email"
                class="input"
                name={field().name}
                value={field().state.value}
                onBlur={field().handleBlur}
                onInput={(event) =>
                  field().handleChange(event.currentTarget.value)
                }
              />
              <Show when={field().state.meta.errors[0]}>
                {(error) => (
                  <span role="alert" class="error">
                    {error().message}
                  </span>
                )}
              </Show>
            </label>
          )}
        </form.Field>
        <button type="submit" class="btn">
          Sign up
        </button>
      </form>
    </Show>
  );
}

Changes to existing files

src/App.tsx (changed)
 import Counter from "./components/Counter";+import SignupForm from "./components/SignupForm";   export default function App() {   return (     <main class="app">       <h1 class="title">my-app</h1>       <Counter />+      <SignupForm />     </main>   ); }⋯ 1 unchanged lines
src/index.css (changed)
⋯ 87 unchanged lines   background: #334155; }  +.form {+  display: flex;+  width: 100%;+  max-width: 24rem;+  flex-direction: column;+  gap: 0.75rem;+}+ +.field {+  display: flex;+  flex-direction: column;+  gap: 0.25rem;+  font-size: 0.875rem;+  font-weight: 500;+}+ +.input {+  border: 1px solid #cbd5e1;+  border-radius: 0.5rem;+  padding: 0.5rem 0.75rem;+  font: inherit;+}+ +.error {+  color: #dc2626;+  font-weight: 400;+}+ 

Project files

Related templates