New recipe: Next.js server actions

Open Beginner friendly
#40 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active

Research direction

Read docs/recipes/express.md for the recipe layout and docs/recipes/README.md for the list. Write docs/recipes/nextjs-server-actions.md with a server action using FormData and safeParse, a client component showing fieldErrors, and a note about string values and transform() for numbers. Run the example in a fresh Next.js app; done when it works and the recipe appears in the README.

Written by the indexing model from the issue text.

Description

documentation good first issue

We have recipes for React Hook Form, TanStack Form, tRPC, Hono and Express in docs/recipes/. Next.js server actions are a common place to validate form data, and safeParse returns fieldErrors in the shape a form needs.

What to write: docs/recipes/nextjs-server-actions.md, following the layout of docs/recipes/express.md:

  • a server action that reads FormData, runs safeParse(schema, Object.fromEntries(formData)) and returns fieldErrors
  • a small client component that shows those errors (for example with useActionState)
  • one note that FormData values are always strings, so number fields need a transform()

Please actually run the example in a fresh Next.js app before opening the pull request, and add the recipe to the list in docs/recipes/README.md.

Dominant language
JavaScript
Stars
0
Forks
7
Avg merge
1h 17m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aniru-dh21/snap-validate

All issues in aniru-dh21/snap-validate

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.