Using templates to start new Nuxt projects
The nuxi cli tool allows us to use templates made by others to initialize a new Nuxt project. The special -t
option in the cli is what we will look at in this post.
The template option with nuxi
The option accepts a template name, or a github repository that is a Nuxt project. Here is a list of names you can use in their github README. For example, you can start a new 'Content' project (which is what this site is built on):
~
npx nuxi init my-blog-site -t content
Here you can replace my-blog-site
with your own project name. You can also use --template
instead of -t.
Start a new Nuxt module project
We will be looking at Nuxt modules later in this course. When we do we'll often be using the following command to start a new Module project:
~
npx nuxi init nuxt-module-name -t module
Starting a project from an existing github template
If you have a base Nuxt project that you always use as a starter and don't want to clone it everytime, or write the boiler-plate, you can use the following syntax:
~
npx nuxi init new-project -t gh:org/repo
For example, my github handle is Eckhardt-D
, and I can have a public repo with the name nuxt-starter-with-prisma
, then everytime I start a new project I can simply run:
~
npx nuxi init new-project-name -t gh:Eckhardt-D/nuxt-starter-with-prisma
Conclusion
This is yet another simple way the Nuxt developer experience goes above and beyond to simplify our lives as developers. Throughout this course we'll be using these tools often, go ahead and play around with using the nuxi
command and templates now if you want to try it out. In the next post we will be doing a deep dive on other cool stuff the nuxi
command provides us.