DEV Community

Cover image for What if Vite had its own nest g? Now it does!
Dmitry Titov
Dmitry Titov

Posted on • Edited on

What if Vite had its own nest g? Now it does!

๐Ÿš€ vite-plugin-create just got a fresh update โ€” v1.1.1 is live!

๐Ÿงฉ You can now:
โ€“ Generate standalone files (perfect for hooks, utils, etc.)
โ€“ Assign a custom basePath for each generator
Itโ€™s a small but powerful step toward more flexible scaffolding.
๐Ÿ‘‰ See whatโ€™s new: https://github.com/dimatitov/vite-plugin-create/releases/tag/1.1.1
Feedback and ideas are always welcome โ€” letโ€™s make Vite development faster together ๐Ÿ’ช

๐Ÿ“ข Update โ€” v1.0.1 is out now!

The new version includes: custom generators, JS/TS template support, per-generator naming styles, and more. ๐Ÿ‘‰ Check out the new features and see examples

Iโ€™ve only recently started sharing articles and documentation publicly.

Previously, all my writing was internal โ€” release notes, docs, research, roadmaps โ€” all within teams.

But after publishing my first Vite plugin, I felt the need to share it with the world. To get feedback. To see if anyone would find it useful. Maybe someone would suggest a feature, spot a bug โ€” or just say โ€œthanks.โ€

And while writing about it, I realized something: I enjoy this. I was already thinking about the next topic. But letโ€™s get back to the plugin.

How It All Started: Inspired by NestJS

Iโ€™ve been a developer for over 5 years โ€” mostly frontend, but Iโ€™ve been getting into backend recently too.

It started with Node.js + Express, and then, at work, we launched a project to automate voice calls and analyze transcripts using OpenAI. I chose to build it with NestJS. I was only mildly familiar with it, but had to dive deep.

And then, I ran:

nest g resource

โ€ฆand boom โ€” a full module appeared.

I literally said out loud:

โ€œWhy doesnโ€™t React have something like this?!โ€

Yes, there are snippets. Yes, some third-party generators exist. But I wanted structure.

I wanted to type a command โ€” and get a scaffolded component. Just like Nest.

The Frontend Pain

Back to a new internal project: a Telegram Web App using Vite + TypeScript + React + Zustand. A simple, small app.

I start coding, and suddenly Iโ€™m back at it again:

  • Create a folder
  • Create Component.tsx
  • Add index.ts
  • Add props interface
  • Import styles
  • โ€ฆand repeat

Eventually, a new page design landed โ€” and I had to do it all over again.

My eye started twitching.

So I wrote a bash script. It scaffolded everything I needed. Made it executable. Called it create-component.

And you know what? I was so happy.

Then came create-store, create-page, and so on. Life got easier.

But there were still problems:

  • Every project has slightly different templates
  • Folder structure varies
  • Sometimes you need something custom โ€” and have to rewrite the script

Especially on legacy projects โ€” one had Angular 1.5 and React mixed in ๐Ÿ˜ตโ€๐Ÿ’ซ

Donโ€™t ask.

Vite Deserves nest g

One day I thought:

โ€œI love Vite. Why not build something like nest g resource โ€” customizable and extensible โ€” for it?โ€

And so vite-plugin-create was born.

A plugin + CLI to quickly generate components, pages, stores, whatever โ€” from your own templates.

Naming? Customizable. Templates? Yours. Command? One.

Building It: Not As Easy As I Thought

I first warmed up with a simple plugin: vite-plugin-import-alias.

It was smaller in scope, helped me get used to publishing, npm, docs, and user feedback.

But I already knew what the next one would be: vite-plugin-create.

The idea looked simple at first. I had my bash scripts. Why not repeat the same logic, just cleaner?

I imagined:

  • Templates for files
  • A config to define structure, names, and naming styles
  • Catch a CLI command like vite create:component Button โ€” and scaffold away

But then came the disappointment

Turns out, Vite has no API to add custom CLI commands.

So vite create:component? Not possible. I really wanted it to feel native, like nest g, but no luck.

The solution: a custom CLI

I added bin/cli.ts, defined commands, and in package.json:

"bin": {
  "vite-create": "./dist/bin/cli.js"
}
Enter fullscreen mode Exit fullscreen mode

Now, everything runs via:

npx vite-create component Button
Enter fullscreen mode Exit fullscreen mode

Not exactly part of Viteโ€™s CLI, but clean, stable, and simple.

Config & Naming

Next step: how should names be formatted?

Components should be PascalCase โ€” but stores or utils? Maybe camelCase or kebab-case.

So I added a fileNameStyle option in the config:

  • pascalCase
  • camelCase
  • kebabCase
  • original (leave as typed)

Default is PascalCase, but I plan to let each generator (component, store, etc.) have its own style.

The Config & Templates

One of my goals: make it dead simple and easy to customize.

You shouldnโ€™t need to guess:

โ€œWhere do templates go?โ€
โ€œWhat format should config be?โ€

Just run:

npx vite-create init
Enter fullscreen mode Exit fullscreen mode

It creates:

templates/ with a base component
vite-create.config.json with a working example

 {
   "defaultPath": "src",
   "fileNameStyle": "pascalCase",
   "generators": {
     "component": {
       "path": "components/{{name}}",
       "files": {
         "{{name}}.tsx": "templates/component/component.tsx",
         "index.ts": "templates/component/index.ts",
         "{{name}}.module.scss": "templates/component/style.scss"
       }
     }
   }
 }
Enter fullscreen mode Exit fullscreen mode

Templates are just .tsx, .ts, .scss files with Handlebars variables like {{name}}, {{PascalCaseName}}, etc.

 import styles from './{{name}}.module.scss';

 export interface Props {
   className?: string;
 }

 export const {{name}}: React.FC<Props> = ({ className }) => {
   return <div className={styles.root}>{{name}} component</div>;
 };
Enter fullscreen mode Exit fullscreen mode

What vite-plugin-create Can Do (Right Now)

โœ… Scaffold any component (or entity) from your templates

โœ… Supports .tsx, .scss, .test.tsx, or whatever you want

โœ… Works with any naming convention

โœ… Lets you define custom generators, like:

npx vite-create store userStore

Enter fullscreen mode Exit fullscreen mode

Or anything you define in the config.

๐Ÿ›ฃ Roadmap

Hereโ€™s what Iโ€™m planning next:

  • โœ… Full support for custom generators
  • ๐Ÿ”€ Choose default format: .tsx or .jsx (maybe via โ€” jsx flag)
  • ๐Ÿ“ Template groups โ€” e.g. pages/, widgets/, shared/
  • โš™๏ธ Per-generator naming style (e.g. PascalCase for components, camelCase for hooks)
  • ๐Ÿงฐ Possibly: a minimal GUI to edit your config visually โ€” in browser or CLI

If youโ€™re tired of boilerplate and repetitive component creation โ€” give vite-plugin-create a try.

Feedback, ideas, PRs โ€” all welcome.

MIT licensed. Open source. Built with โค๏ธ

Top comments (0)