Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
next-safe-action avatar

Safe Action Advanced

  • 1k installs
  • Updated July 18, 2026
  • next-safe-action/skills

safe-action-advanced is a Next.js agent skill that implements bind arguments, metadata, framework errors, and type utilities in next-safe-action for developers building production-grade server actions.

About

safe-action-advanced is an official skill from next-safe-action/skills for engineers extending beyond basic server action validation. It documents bind arguments via .bind() for resource IDs, typed metadata schemas consumed in middleware, framework error handling for redirect, notFound, forbidden, and unauthorized, plus InferSafeActionFnInput and InferSafeActionFnResult type utilities. Server-level action callbacks round out production patterns. Developers reach for this skill when next-safe-action actions need parameterized binds, middleware metadata, or Next.js navigation errors handled safely inside action boundaries. The skill targets TypeScript Next.js App Router projects already using next-safe-action who need advanced typing and control flow without breaking end-to-end type inference between client hooks and server handlers.

  • Bind arguments support for passing extra context like resource IDs
  • Typed metadata attachment for middleware and server logic
  • Built-in handling of redirect, notFound, forbidden, and unauthorized framework errors
  • Type inference utilities including InferSafeActionFnInput and InferSafeActionFnResult
  • Server-level callbacks: onSuccess, onError, and onSettled that execute exclusively on the server

Safe Action Advanced by the numbers

  • 1,025 all-time installs (skills.sh)
  • +25 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #388 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/next-safe-action/skills --skill safe-action-advanced

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1k
Security audit3 / 3 scanners passed
Last updatedJuly 18, 2026
Repositorynext-safe-action/skills

How do you handle redirect errors in server actions?

Safely implement complex server actions with bind arguments, metadata, framework errors, and server callbacks in Next.js applications.

Who is it for?

Next.js TypeScript developers extending next-safe-action with binds, metadata, framework errors, and inferred action types.

Skip if: Projects not using next-safe-action, client-only React apps without server actions, or teams needing only basic Zod validation patterns.

When should I use this skill?

The user works with next-safe-action bind arguments, metadata schemas, redirect or notFound in actions, or InferSafeActionFn types.

What you get

Typed server actions with bind arguments, metadata middleware hooks, framework error handlers, and inferred input or result types.

  • typed server actions with binds
  • metadata-aware middleware
  • framework error handlers

Files

SKILL.mdMarkdownGitHub ↗

next-safe-action Advanced Features

Overview

FeatureUse Case
Bind argumentsPass extra args to actions via .bind() (e.g., resource IDs)
MetadataAttach typed metadata to actions for use in middleware
Framework errorsHandle redirect, notFound, forbidden, unauthorized in actions
Type utilitiesInfer types from action functions and middleware

Server-Level Action Callbacks

The second argument to .action() accepts callbacks that run on the server (not client-side hooks):

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

Related skills

How it compares

Use safe-action-advanced after basic next-safe-action setup; pick generic Next.js skills when not using the next-safe-action library.

FAQ

What framework errors does safe-action-advanced cover?

safe-action-advanced documents handling redirect, notFound, forbidden, and unauthorized errors inside next-safe-action server actions so Next.js navigation and auth flows work without breaking action contracts.

What are bind arguments in next-safe-action?

safe-action-advanced explains passing extra arguments to server actions through .bind(), such as resource IDs, while preserving next-safe-action validation and type inference on the bound action function.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.