Skip to content

feat: add support for custom templates#1340

Draft
manchenkoff wants to merge 1 commit into
nuxt:mainfrom
manchenkoff:extend-templates-cli
Draft

feat: add support for custom templates#1340
manchenkoff wants to merge 1 commit into
nuxt:mainfrom
manchenkoff:extend-templates-cli

Conversation

@manchenkoff

@manchenkoff manchenkoff commented Jun 11, 2026

Copy link
Copy Markdown

This PR is a proposal rather than final implementation.

🔗 Linked issue

Resolves #56

📚 Description

This PR using new hook introduced in nuxt/nuxt#35345 for collecting available file templates from client modules.

This allows clients to define custom set of files to generate via pnpm nuxt add-template <custom-template-from-module> filename.

Example of the client module:

import { defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule({
  meta: {
    name: 'custom-component',
  },
  setup(_options, nuxt) {
    nuxt.hook('templates:extend', (templates: Record<string, unknown>) => {
      templates['custom-component'] = ({ name }: { name: string }) => ({
        path: `components/custom/${name}.vue`,
        contents: `\
<template>
  <div>
    {{ name }}
  </div>
</template>

<script setup lang="ts">
defineProps<{name: string}>()
</script>`,
      })
    })
  },
})

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a146876). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1340   +/-   ##
=======================================
  Coverage        ?   52.47%           
=======================================
  Files           ?       49           
  Lines           ?     1214           
  Branches        ?      339           
=======================================
  Hits            ?      637           
  Misses          ?      473           
  Partials        ?      104           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Jun 11, 2026

Copy link
Copy Markdown
  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1340
    
    npm i https://pkg.pr.new/nuxi@1340
    
    npm i https://pkg.pr.new/@nuxt/cli@1340
    

commit: 7efa328

@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing manchenkoff:extend-templates-cli (7efa328) with main (fab0173)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extendable nuxi add with custom templates from modules

2 participants