Installation
To get started quickly, the Nuxt.js team has created scaffolding tool create-nuxt-app.
Make sure you have installed (npx
is shipped by default since NPM 5.2.0
)
Or with yarn:
$ yarn create nuxt-app <project-name>
It will ask you some questions:
- Choose between integrated server-side frameworks:
- Choose your favorite testing framework:
- None (feel free to add one later)
- Jest
- The Nuxt mode you want (
Universal
orSPA
) - Add to Lint your code on save.
- Add Prettier to prettify your code on save. When answered, it will install all the dependencies so the next step is to navigate to the project folder and launch it with:
$ cd <project-name>
$ npm run dev
The application is now running on .
To discover more about the directory structure of the project: Directory Structure Documentation.
Starting from scratch
Creating a Nuxt.js project from scratch is easy, only 1 file and 1 directory are required. Create an empty directory to start:
Info: replace <project-name>
with a name for the project.
Every project needs a file to start nuxt
. Copy this json into your package.json and save before running npm install (below):
{
"name": "my-app",
"scripts": {
"dev": "nuxt"
}
}
scripts
will launch Nuxt.js via npm run dev
.
$ npm install --save nuxt
Nuxt.js transforms every *.vue
file inside a pages
directory as a route for the application.
Create the pages
directory:
then create the first page in pages/index.vue
:
<template>
<h1>Hello world!</h1>
</template>
and launch the project with:
The application is now running on http://localhost:3000.
To discover more about the directory structure of the project: .