Skip to content

Templates ​

This page documents the templates feature, its configuration contract and the recommended usage pattern for application developers.

Purpose ​

The templates feature helps keep the Nuxt module configuration, Feathers runtime, generated services, TypeScript client and CLI workflow aligned.

When to use this option ​

Use this page when you need to:

  • configure the templates feature;
  • document the decision in a starter or application;
  • validate the setup with a CLI command;
  • avoid drift between configuration, generated files and runtime behavior.

Configuration example ​

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-feathers-zod'],

  feathers: {
    templates: {
      dirs: ['feathers/templates'],
      strict: true,
    },
  }
})

REST handler format ​

The Express REST transport uses the generated server/rest-bridge.mjs template. It must remain an ESM JavaScript module directly parseable by Nitro/Rollup; maintainer types are carried by JSDoc and checked before the build.

CLI example ​

bash
bunx nuxt-feathers-zod init templates --dir feathers/templates --force

Runtime example ​

ts
const service = useService('messages')

const result = await service.find({
  query: {
    $limit: 10,
    $sort: { createdAt: -1 },
  },
})

Practical advice ​

  • Keep runtime-affecting options explicit in nuxt.config.ts.
  • Prefer CLI-generated services so manifests and generated types stay synchronized.
  • Run bunx nuxt-feathers-zod doctor after structural changes.
  • Use --dry before write operations on an existing project.

nuxt-feathers-zod user documentation