You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(action-client): export a copy of safe action client from /zod path (#115)
Sometimes, TypeSchema causes errors with its dynamic import system, to handle multiple validation libraries.
The code in this PR exports a copy of the safe action client from the `/zod` path, that support just Zod validation library, as the name implies. This should fix problems with the edge runtime and hopefully future bundler issues too.
Copy file name to clipboardexpand all lines: website/docs/getting-started.md
+4
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,10 @@ description: Getting started with next-safe-action version 7.
18
18
19
19
We will use Zod as our validation library in this documentation, but since version 6 of next-safe-action, you can use your validation library of choice, or even multiple and custom ones at the same time, thanks to the **TypeSchema** library. Note that we also need to install the related TypeSchema adapter for our validation library of choice. You can find supported libraries and related adapters [here](https://typeschema.com/#coverage).
20
20
21
+
:::info
22
+
If you experience an issue related to TypeSchema, check out the ["Errors with TypeSchema"](/docs/troubleshooting/errors-with-typeschema) section of the troubleshooting page to see how to fix it.
23
+
:::
24
+
21
25
## Installation
22
26
23
27
For Next.js >= 14, assuming you want to use Zod as your validation library, use the following command:
[TypeSchema](https://typeschema.com/) library relies on dynamic imports to support a wide range of validation libraries. It works well most of the time, but in some cases it can cause unexpected errors.
9
+
10
+
For instance, there's a known bug with TypeSchema and Next.js edge runtime. When parsing and validating client input, the server outputs the following error:
To solve this, next-safe-action exports a copy of the safe action client from the `/zod` path, with the exact same functionality as the default one. The only difference is that this client **requires** Zod to work, as it supports just that validation library.
18
+
19
+
So, after you installed `next-safe-action`, `zod` and `@typeschema/zod` packages, as explained in the [installation](/docs/getting-started#installation) section of the getting started page, you just need to update the import path for `createSafeActionClient`, in the `safe-action.ts` file:
0 commit comments