Getting Started

Installation

Install nuxt-safe-action, the type-safe server action module for Nuxt 3 and Nuxt 4 with Zod v3 and v4 support.

Installation

Quick Setup

The fastest way to add nuxt-safe-action to your Nuxt project:

Terminal
npx nuxi module add nuxt-safe-action

This will install the module and add it to your nuxt.config.ts automatically.

Manual Installation

If you prefer to install manually:

pnpm add nuxt-safe-action zod
Zod v4 supportednuxt-safe-action works with both Zod v3 (^3.20.0) and Zod v4 (^4.0.0). No code changes are needed when upgrading.

Then add it to your nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-safe-action'],
})

Configuration

You can configure the module in your nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-safe-action'],
  safeAction: {
    actionsDir: 'actions', // relative to server/ directory (default: 'actions')
  },
})
OptionTypeDefaultDescription
actionsDirstring'actions'Directory inside server/ where action files are located

That's it! You're ready to create your first action.

Copyright © 2026