Can I use "next-safe-actions" library for queries, with no "use server"? I just need a validation

What will happen if I create an action client
export const action = createSafeActionClient();

// import it inside of "/src/server/queries.ts"
// with no "use server" directive
import { z } from "zod";

import { action } from "~/lib/safe-action";
import { db } from "~/server/db";

const getArticleSchema = z.object({
id: z.string().cuid(),
});

export const getArticle = action(getArticleSchema, async ({ id }) => {
const article = await db.article.findUnique({
where: { id },
select: {
id: true,
},
});

return { article };
});
export const action = createSafeActionClient();

// import it inside of "/src/server/queries.ts"
// with no "use server" directive
import { z } from "zod";

import { action } from "~/lib/safe-action";
import { db } from "~/server/db";

const getArticleSchema = z.object({
id: z.string().cuid(),
});

export const getArticle = action(getArticleSchema, async ({ id }) => {
const article = await db.article.findUnique({
where: { id },
select: {
id: true,
},
});

return { article };
});
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server