From b2d990d40ae5ad94457922b2b7e549abbeaf12a1 Mon Sep 17 00:00:00 2001 From: Roj Date: Thu, 4 May 2023 20:58:05 +0300 Subject: [PATCH 1/2] Improve README --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e7da7ae..5431607 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Zact - Zod Server ACTions -We like NextJS Server Actions. We wanted to love them. This package makes them validated and typesafe, so you can use them in things that aren't forms. +We like Next.js Server Actions. We wanted to love them. This package makes them validated and type-safe, so you can use them in things that aren’t forms. -`npm install zact` +```shell +npm install zact +``` + +### Back End -### Backend ```ts // action.ts "use server"; @@ -18,7 +21,8 @@ export const validatedAction = zact(z.object({ stuff: z.string().min(6) }))( ); ``` -### Client WITH custom hook +### Client WITH Custom Hook + ```ts // component.tsx "use client"; @@ -41,8 +45,9 @@ export const zactTestComponent = () => { }; ``` -### Client WITHOUT custom hook -Yes you can just import them and call them like promises too +### Client WITHOUT Custom Hook + +Yes you can just import them and call them like promises, too: ```ts // component.tsx From 6df4f4d704efe94a86851023343221d46d61bc86 Mon Sep 17 00:00:00 2001 From: Roj Date: Thu, 4 May 2023 20:59:16 +0300 Subject: [PATCH 2/2] I thought about it --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5431607..9349a92 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ npm install zact import { z } from "zod"; import { zact } from "zact/server"; + export const validatedAction = zact(z.object({ stuff: z.string().min(6) }))( async (input) => { return { message: `hello ${input.stuff}` }; @@ -47,7 +48,7 @@ export const zactTestComponent = () => { ### Client WITHOUT Custom Hook -Yes you can just import them and call them like promises, too: +Yes, you can also just import them and call them like promises: ```ts // component.tsx @@ -56,7 +57,6 @@ Yes you can just import them and call them like promises, too: import { validatedAction } from "./action"; export const zactTestComponent = () => { - return (