Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# 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 arent forms.

`npm install zact`
```shell
npm install zact
```

### Back End

### Backend
```ts
// action.ts
"use server";

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}` };
}
);
```

### Client WITH custom hook
### Client WITH Custom Hook

```ts
// component.tsx
"use client";
Expand All @@ -41,8 +46,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 also just import them and call them like promises:

```ts
// component.tsx
Expand All @@ -51,7 +57,6 @@ Yes you can just import them and call them like promises too
import { validatedAction } from "./action";

export const zactTestComponent = () => {

return (
<div className="flex flex-col text-xl gap-4 text-center">
<button onClick={() => {
Expand Down