CLI
The CLI bunx nuxt-feathers-zod is the official method to initialize a Nuxt 4 app, generate NFZ-compatible artifacts and diagnose an existing project.
This page is aligned with the OSS command surface stabilized for release 6.4.13.
Entry command
bunx nuxt-feathers-zod <command> [args] [--flags]Official OSS CLI surface
Recommended public core
init embeddedinit remoteremote auth keycloakadd service <name>add remote-service <name>add middleware <name>schema <service>auth service <name>mongo managementdoctor
Secondary commands / compatibility aliases
add custom-service <name>init templatestemplates listplugins list|addmodules list|addmiddlewares list|addadd server-module <name>add mongodb-compose
Initialization
init templatesinit embeddedinit remoteremote auth keycloak
Services
add service <name>add service <name> --customadd remote-service <name>auth service <name>schema <service>
Runtime artifacts
add middleware <name>add server-module <name>add mongodb-composemongo management
OSS asset helpers
templates listplugins listplugins add <name>modules listmodules add <name>middlewares listmiddlewares add <name>
Diagnostics
doctor
Differences between plugin, server-module, module, client-module, hook, policy
These targets are not equivalent. The right way to choose is: where the file is generated, when it runs, and which problem it solves.
plugin
A plugin is a global server-side Feathers plugin.
Associated CLI command:
bunx nuxt-feathers-zod plugins add audit-bootstrapGenerated file:
server/feathers/audit-bootstrap.tsUse it when:
- you need to attach global logic to the Feathers application
- you want to register
app.hooks({ setup: [...] }) - you need cross-cutting server bootstrap code
Example usage:
import { auditBootstrap } from '~/server/feathers/audit-bootstrap'
export default defineNitroPlugin(async () => {
// the NFZ runtime loads the server plugin
})Typical cases: global logging, metrics, application-level bootstrap hooks.
server-module
A server-module is a server infrastructure module loaded around the Feathers/Nitro runtime.
Associated CLI command:
bunx nuxt-feathers-zod add server-module security-headersGenerated file:
server/feathers/modules/security-headers.tsUse it when:
- you need to add HTTP headers
- you want to wire
helmet, rate-limit, healthcheck, request logger - you are modifying the server layer more than Feathers business logic
Example usage:
export default async function securityHeaders(app: any) {
app.use((req: any, res: any, next: any) => {
res.setHeader('X-Frame-Options', 'DENY')
next()
})
}Typical cases: HTTP hardening, health endpoints, Express/Koa middleware.
module
module is currently a practical alias for server-module in the CLI.
Associated CLI command:
bunx nuxt-feathers-zod add middleware request-logger --target moduleGenerated file:
server/feathers/modules/request-logger.tsUse it when:
- you prefer the shorter
moduletarget - otherwise prefer
server-module, which is clearer in the docs
Example usage:
bunx nuxt-feathers-zod add middleware healthcheck --target moduleSame usage family as server-module.
client-module
A client-module is a Nuxt client plugin loaded only in the browser.
Associated CLI command:
bunx nuxt-feathers-zod add middleware api-debug --target client-moduleGenerated file:
app/plugins/api-debug.client.tsUse it when:
- you want to enrich
$api - you need client-side diagnostics
- you want browser-side telemetry
Example usage:
export default defineNuxtPlugin((nuxtApp) => {
console.info('[nfz] client module ready', !!nuxtApp.$api)
})Typical cases: Feathers client debugging, frontend instrumentation, browser-only helpers.
hook
A hook is a reusable Feathers hook function.
Associated CLI command:
bunx nuxt-feathers-zod add middleware attach-tenant --target hookGenerated file:
server/feathers/hooks/attach-tenant.tsUse it when:
- you need to enrich
context.params - you want to transform
context.data - you need reusable before/after/around logic
Example usage:
import { attachTenant } from '../hooks/attach-tenant'
export const before = {
all: [attachTenant()]
}Typical cases: multi-tenant context, data normalization, context enrichment.
policy
A policy is a specialized authorization guard.
Associated CLI command:
bunx nuxt-feathers-zod add middleware is-admin --target policyGenerated file:
server/feathers/policies/is-admin.tsUse it when:
- you need explicit allow/deny logic
- you want a centralized RBAC rule
- you want to protect a service or a method
Example usage:
import { isAdminPolicy } from '../policies/is-admin'
export const before = {
all: [isAdminPolicy()]
}Typical cases: admin-only, same-user-or-admin, business access control rules.
Practical summary
plugin: global server-side Feathers extensionserver-module: server/infrastructure extensionmodule: alias ofserver-moduleclient-module: Nuxt client pluginhook: reusable Feathers hook logicpolicy: authorization-focused hook
Minimum stability check
bunx nuxt-feathers-zod --help
bunx nuxt-feathers-zod doctorRecommended path: new Nuxt 4 app
Embedded
bunx nuxi@latest init my-nfz-app
cd my-nfz-app
bun install
bun add nuxt-feathers-zod feathers-pinia
bun add -D @pinia/nuxt
bunx nuxt-feathers-zod init embedded --force
bunx nuxt-feathers-zod add service users
bun devEmbedded + local auth
bunx nuxi@latest init my-nfz-auth
cd my-nfz-auth
bun install
bun add nuxt-feathers-zod feathers-pinia feathers-swagger swagger-ui-dist
bun add -D @pinia/nuxt
bunx nuxt-feathers-zod init embedded --force --auth --swagger
bunx nuxt-feathers-zod add service users --auth --adapter mongodb --schema zod --collection users --idField _id --docs
bun devRemote
bunx nuxi@latest init my-nfz-remote
cd my-nfz-remote
bun install
bun add nuxt-feathers-zod feathers-pinia
bun add -D @pinia/nuxt
bunx nuxt-feathers-zod init remote --url https://api.example.com --transport socketio --force
bunx nuxt-feathers-zod add remote-service users --path users --methods find,get,create,patch,remove
bun devImportant DX rules
- default adapter =
memory - default schema =
none - recommended
servicesDirs=['services'] - in embedded mode, generate services through the CLI
- in remote mode,
transport: autocurrently resolves to socketio add custom-serviceremains supported, but the public recommended form isadd service <name> --custom
init templates
Initializes a template override directory.
bunx nuxt-feathers-zod init templates --dir feathers/templatesUseful flags:
--dir <dir>--force--dry--diff
init embedded
Initializes embedded mode: a Feathers server inside Nitro.
bunx nuxt-feathers-zod init embedded --forceImportant flags:
--framework express|koa--servicesDir <dir>--restPath <path>--websocketPath <path>--websocketTransports <list>--websocketConnectTimeout <ms>--websocketCorsOrigin <value>--websocketCorsCredentials true|false--websocketCorsMethods <list>--secureDefaults true|false--cors true|false--compression true|false--helmet true|false--bodyParserJson true|false--bodyParserUrlencoded true|false--serveStatic true|false--serveStaticPath <path>--serveStaticDir <dir>--serverModulesPreset <name>--expressBaseline--auth true|false--swagger true|false--force--dry
init remote
Initializes remote mode: a Feathers client against an external server.
bunx nuxt-feathers-zod init remote --url https://api.example.com --transport socketio --forceImportant flags:
--url <http(s)://...>--transport socketio|rest|auto--restPath <path>--websocketPath <path>--websocketTransports <list>--websocketConnectTimeout <ms>--websocketCorsOrigin <value>--websocketCorsCredentials true|false--websocketCorsMethods <list>--auth true|false--payloadMode jwt|keycloak--strategy <name>--tokenField <name>--servicePath <path>--reauth true|false--force--dry
remote auth keycloak
Configures the Keycloak bridge in the app.
bunx nuxt-feathers-zod remote auth keycloak --ssoUrl https://sso.example.com --realm myrealm --clientId myappadd service <name>
Generates an embedded service.
bunx nuxt-feathers-zod add service users --adapter mongodb --schema zod --collection users --idField _idUseful flags:
--custom--type adapter|custom--adapter memory|mongodb--schema none|zod|json--auth true|false--authAware true|false--idField id|_id--path <servicePath>--collection <name>--methods find,get,create,patch,remove--customMethods run,preview--docs true|false--servicesDir <dir>--force--dry
Auth-aware users generation
--auth protects service methods with JWT hooks. --authAware controls local-auth-specific password handling.
Examples:
bunx nuxt-feathers-zod add service users --auth --schema none --adapter memory --force
bunx nuxt-feathers-zod add service users --auth --schema zod --adapter mongodb --collection users --idField _id --force
bunx nuxt-feathers-zod add service users --auth --authAware false --schema json --adapter memory --forceadd remote-service <name>
Adds a client-only service into feathers.client.remote.services.
bunx nuxt-feathers-zod add remote-service users --path users --methods find,get,create,patch,removeauth service <name>
Enables or disables JWT auth hooks on an existing embedded service.
bunx nuxt-feathers-zod auth service users --enabled true
bunx nuxt-feathers-zod auth service users --enabled falseschema <service>
Inspects or mutates the service manifest schema state.
bunx nuxt-feathers-zod schema users --show
bunx nuxt-feathers-zod schema users --json
bunx nuxt-feathers-zod schema users --set-mode zod
bunx nuxt-feathers-zod schema users --add-field title:string!
bunx nuxt-feathers-zod schema users --rename-field title:headlineMain flags:
--show--json--export--get--set-mode none|zod|json--add-field <spec>--remove-field <name>--set-field <spec>--rename-field <from:to>--validate--repair-auth--diff--servicesDir <dir>--force--dry
--validate checks manifest ↔ generated-files coherence. --repair-auth restores the expected baseline for an auth-compatible users service. --diff helps inspect drift before writing changes.
add middleware <name>
Generates a middleware artifact. Supported targets include Nitro middleware, Nuxt route middleware, Feathers plugins, hooks, policies, and embedded server modules.
bunx nuxt-feathers-zod add middleware trace-headers --target nitro
bunx nuxt-feathers-zod add middleware auth-keycloak --target routeSupported targets:
- recommended public targets:
nitro,route - advanced targets:
feathers,server-module,module,client-module,hook,policy
Public docs recommend starting with nitro and route. The other targets remain supported but mostly address expert or internal scaffolding needs.
add server-module <name>
Directly generates an embedded server module in server/feathers/modules.
bunx nuxt-feathers-zod add server-module helmet --preset helmet
bunx nuxt-feathers-zod add server-module express-baseline --preset express-baselineadd mongodb-compose
Generates a docker-compose-db.yaml file to bootstrap MongoDB locally.
bunx nuxt-feathers-zod add mongodb-compose
bunx nuxt-feathers-zod add mongodb-compose --out docker-compose-db.yaml --service mongodb --database app --rootUser root --rootPassword change-memongo management
Enables or updates the embedded MongoDB management surface in nuxt.config.*.
bunx nuxt-feathers-zod mongo management --url mongodb://root:change-me@127.0.0.1:27017/app?authSource=admin --enabled true --auth false --basePath /mongoUseful flags:
--url <mongodb-url>--enabled true|false--auth true|false--basePath <path>--exposeDatabasesService true|false--exposeCollectionsService true|false--exposeUsersService true|false--exposeCollectionCrud true|false--dry
Canonical routes:
/mongo/databases(legacy alias accepted:/mongo)/mongo/<db>/collections/mongo/<db>/stats/mongo/<db>/<collection>/indexes/mongo/<db>/<collection>/count/mongo/<db>/<collection>/schema/mongo/<db>/<collection>/documents/mongo/<db>/<collection>/aggregate
OSS helpers: templates, plugins, modules, middlewares
templates list
Lists available OSS templates.
bunx nuxt-feathers-zod templates listplugins list / plugins add <name>
bunx nuxt-feathers-zod plugins list
bunx nuxt-feathers-zod plugins add audit-logThe generator creates a Feathers server plugin based on defineFeathersServerPlugin.
modules list / modules add <name>
bunx nuxt-feathers-zod modules list
bunx nuxt-feathers-zod modules add security-headers --preset security-headersThe generator creates a Feathers server module based on defineFeathersServerModule.
middlewares list / middlewares add <name>
bunx nuxt-feathers-zod middlewares list --target nitro
bunx nuxt-feathers-zod middlewares add request-id --target nitrodoctor
Quick diagnosis for the current project.
bunx nuxt-feathers-zod doctorThe report covers:
- client mode (
embedded/remote) - remote transport and target URL
- detected
servicesDirs - scanned local services
- remote Keycloak config
- Mongo management config with:
- redacted URL
- normalized
basePath - computed route surface
- warning when
management.enabled = truebutdatabase.mongo.urlis missing
