leerob / next-saas-starter

Get started quickly with Next.js, Postgres, Stripe, and shadcn/ui.
https://next-saas-start.vercel.app
MIT License
5.49k stars 616 forks source link

UX on forms #50

Closed elie-h closed 1 month ago

elie-h commented 1 month ago

Great repo and example, I was hoping to use this repo as a guiding example on how to implement server actions and forms with the new paradigm. But I'm struggling to see how this new simple model of form management can be used without serious degradations to form UX.

Some observations & questions:

A code snippet that addresses these points will be very beneficial.

leerob commented 1 month ago
  1. Here's an example of one of the forms where I'm keeping the client inputs: https://github.com/leerob/next-saas-starter/blob/b9bfeedc6f27558c15b9c3562e78e883cdca5c2a/app/(dashboard)/dashboard/general/page.tsx#L24-L36
  2. I do have client side validation using HTML in some places. I don't view going to the server on submission as a negative position.
  3. This could be changed if you prefer to have more inline errors! It's not something I'm planning to do here but wouldn't be much more work 😄
  4. Same here, good idea but not something I'm planning on doing here. You can look at the state returned from useActionState and use that with a toast library from shadcn/ui, like Sonner.