+1
Daily
5,926
stars
275
forks
52
watchers
175
prs
280
issues
62
releases
README
hygen is the simple, fast, and scalable code generator that lives _in_ your project.
Features
- ✅ Build ad-hoc generators quickly and full on project scaffolds.
- ✅ Local generators per project (and global, if you must)
- ✅ Built-in scaffolds to quickly create generators
- ✅ Full logic templates and rendering
- ✅ Prompts and flows for taking in arguments
- ✅ Automatic CLI arguments
- ✅ Adding new files
- ✅ Injecting into existing files
- ✅ Running shell commands
- ✅ Super fast, constantly optimized for speed
New in hygen v4.0.0: a positional NAME parameter.
Now you can use $ hygen component new MyComponent instead of $ hygen component new --name MyComponent.
Used By
Quick Start
Hygen can be used to supercharge your workflow with Redux, React Native, Express and more, by allowing you avoid manual work and generate, add, inject and perform custom operations on your codebase.
If you're on macOS and have Homebrew:
$ brew tap jondot/tap
$ brew install hygen
If you have node.js installed, you can install globally with npm (or Yarn):
$ npm i -g hygen
If you like a no-strings-attached approach, you can use npx without installing globally:
$ npx hygen ...
For other platforms, see releases.
Initialize hygen in your project (do this once per project):
$ cd your-project
$ hygen init self
Build your first generator, called mygen:
$ hygen generator new mygen
Loaded templates: _templates
added: _templates/mygen/new/hello.ejs.t
Now you can use it:
$ hygen mygen new
Loaded templates: _templates
added: app/hello.js
You've generated content into the current working directory in app/. To see how the generator is built, look at _templates (which you should check-in to your project from now on, by the way).
You can build a generator that uses an interactive prompt to fill in a variable:
$ hygen generator with-prompt mygen
Loaded templates: _templates
added: _templates/mygen/with-prompt/hello.ejs.t
added: _templates/mygen/with-prompt/prompt.js
Done! Now let's use mygen:
$ hygen mygen with-prompt
? What's your message? hello
Loaded templates: _templates
added: app/hello.js
Use a template repo
Want to start from a repo?
$ hygen init repo antfu/vitesse --to my-folder
Want to start from an existing repo on an existing project?
$ mkdir your-project && cd your-project
$ hygen init repo antfu/vitesse
What's Next?
Go to the documentation to get to know the rest of Hygen and generators.
If you're in a hurry:
To learn how to edit generator templates, look here
To see how to use generators look here
Take a look at the ecosystem and tooling built around Hygen.
A Different Kind of a Generator
hygen Top issues
#158monorepo multi-team/multi-project folder structure17 comments · 2019-10-25#92Add ESM support to JS files12 comments · 2019-01-02#162JSON injection9 comments · 2019-10-28#275hygen init self fails if _templates directory is present7 comments · 2020-11-20#111How to load local variables from JSON?7 comments · 2019-04-01#84[feature] Replace a line during inject6 comments · 2018-12-04#458Is Hygen dead?5 comments · 2025-04-22#443Kindly asking... is this still maintained?5 comments · 2024-03-19