safe-action-advanced

Use when working with bind arguments, metadata schemas, framework errors (redirect/notFound/forbidden/unauthorized), type inference utilities…

INSTALLATION
npx skills add https://github.com/next-safe-action/skills --skill safe-action-advanced
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$27

export const createPost = authActionClient

  .inputSchema(schema)

  .action(

    async ({ parsedInput, ctx }) => {

      const post = await db.post.create(parsedInput);

      return post;

    },

    {

      onSuccess: async ({ data, parsedInput, ctx, metadata, clientInput }) => {

        // Runs on the server after successful execution

        await invalidateCache("posts");

      },

      onError: async ({ error, metadata, ctx, clientInput, bindArgsClientInputs }) => {

        // error: { serverError?, validationErrors? }

        await logError(error);

      },

      onSettled: async ({ result }) => {

        // Always runs

        await recordMetrics(result);

      },

      onNavigation: async ({ navigationKind }) => {

        // Runs when a framework error (redirect, notFound, etc.) occurs

        console.log("Navigation:", navigationKind);

      },

    }

  );

These are distinct from hook callbacks (useAction({ onSuccess })) — server callbacks run in the Node.js runtime, hook callbacks run in the browser.

throwServerError

Re-throw server errors instead of returning them as result.serverError:

export const myAction = actionClient

  .inputSchema(schema)

  .action(serverCodeFn, {

    throwServerError: true,

    // The handled server error (return of handleServerError) is thrown

  });
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card