Installation

Nuxt.js is really easy to get started with. A simple project only needs the nuxt dependency.

Using create-nuxt-app

To get started quickly, the Nuxt.js team has created scaffolding tool create-nuxt-app.

Make sure you have npx installed (npx is shipped by default since NPM 5.2.0)

  1. $ npx create-nuxt-app <project-name>

Or with yarn:

  1. $ yarn create nuxt-app <project-name>

It will ask you some questions:

  1. $ cd <project-name>
  2. $ npm run dev

The application is now running on http://localhost:3000.

Nuxt.js will listen for file changes inside the pages directory, so there is no need to restart the application when adding new pages.

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:

  1. $ mkdir <project-name>
  2. $ cd <project-name>

Info: replace <project-name> with a name for the project.

The package.json

Every project needs a package.json file to start nuxt. Copy this json into your package.json and save before running npm install (below):

  1. {
  2. "name": "my-app",
  3. "scripts": {
  4. "dev": "nuxt"
  5. }
  6. }

scripts will launch Nuxt.js via npm run dev.

Installing nuxt

With the package.json created, add nuxt to the project via npm:

  1. $ npm install --save nuxt

The pages directory

Nuxt.js transforms every *.vue file inside a pages directory as a route for the application.

Create the pages directory:

  1. $ mkdir pages

then create the first page in pages/index.vue:

  1. <template>
  2. <h1>Hello world!</h1>
  3. </template>

and launch the project with:

  1. $ npm run dev

The application is now running on http://localhost:3000.

Nuxt.js will listen for file changes inside the pages directory, so there is no need to restart the application when adding new pages.

To discover more about the directory structure of the project: Directory Structure Documentation.