SlideShare a Scribd company logo
Nuxt.js - Introduction
A minimalist framework
for server-rendered Vue.js applications
Inspired by Next.js
Built on top of Vue.js 2
Server-side Rendering
With Node.js
ES6 Transpilation
With Babel
Code Splitting
With Webpack
Focus on writing
*.vue files
Example
npm install --save nuxt
package.json
{
“dependencies": {
“nuxt”: "latest"
},
“scripts”: {
“dev”: “nuxt"
}
}
pages/index.vue
<template>
<h1>Hello {{ name }}</h1>
</template>
<script>
export default {
data () {
return { name: ‘world’ }
}
}
</script>
npm run dev
http://localhost:3000
<h1>Hello world</h1>
pages/ is the main API
pages/index.vue —> /
pages/about.vue —> /about
Async Data
pages/index.vue
<template>
<ul>
<li v-for=“post in posts”>
{{ post.title }}
</li>
</ul>
</template>
<script>
import axios from 'axios'
export default {
data () {
return axios.get(‘https://my-api')
.then((res) => {
return { posts: res.data }
})
}
}
</script>
Server Data
pages/index.vue
<template>
<h1>Hi from {{ name }}</h1>
</template>
<script>
export default {
data ({ req }) {
return {
name: (req ? ‘server' : ‘client' }
}
}
}
</script>
data(context)
- isServer
- isClient
- isDev
- req
- res
- params
- query
- env
- route
- base
- store
- error({ statusCode, message })
- redirect([status], path, [query])
pages/auth.vue
<template>
<h1>Authenticated</h1>
</template>
<script>
export default {
data ({ store, redirect }) {
if (store.user.authUser)
return redirect(‘/login’)
return {}
}
}
</script>
Customisable
nuxt.config.js
Custom Routes
Ex: pages/users/_id.vue -> /users/:id
Vue plugins
Ex: vuelidate, vue-i18n, etc.
nuxt.config.js
module.exports = {
plugins: [
‘plugins/vuelidate.js’
],
build: {
vendor: [‘vuelidate’]
}
}
plugins/vuelidate.js
import Vue from 'vue'
import Validation from 'vuelidate'
Vue.use(Validation)
Head elements
title, meta tags, etc.
nuxt.config.js
module.exports = {
head: {
title: ‘Default title’,
meta: [
{ charset: ‘utf-8’ }
]
}
}
pages/index.vue
<template>
<h1>Hello world</h1>
</template>
<script>
export default {
head: {
title: ‘Index page'
}
}
</script>
Vuex Store
With store/index.js
router/index.js
import Vuex from 'vuex'
const store = new Vuex.Store({
state: {
counter: 0
},
mutations: {
increment (state) {
state.counter++
}
}
})
export default store
pages/index.vue
<template>
<button @click=“$store.commit(‘increment’)">
{{ $store.state.counter }}
</button>
</template>
Layouts
layouts/app.vue
layouts/app.vue
<template>
<nuxt-container>
<p>My nav bar here!</p>
<nuxt></nuxt>
</nuxt-container>
</template>
<style src=“~assets/main.css”></style>
Etc.
- Routes Transitions
- Static files
- Error page
- Testing
- Environment variables
- postcss plugins
- babel configuration
- webpack config
Use it
Programmatically
server.js
const Nuxt = require(‘nuxt')
const nuxt = new Nuxt(options)
nuxt.build()
.then(() => {
// nuxt.renderRoute(‘/‘)
})
Express Middleware
app.use(nuxt.render)
server.js
const Nuxt = require(‘nuxt’)
const app = require(‘express’)()
new Nuxt(options)
.then((nuxt) => {
app.use(nuxt.render)
app.listen(3000)
})
Server Deployment
package.json
{
“dependencies": {
“nuxt”: "latest"
},
“scripts”: {
“dev”: “nuxt”,
“build”: “nuxt build”,
“start”: “nuxt start"
}
}
Serverless Deployment
nuxt generate
pages/index.vue —> /index.html
pages/about.vue —> /about/index.html
nuxtjs.org
Chopin brothers
Made with nuxt.js

More Related Content

PDF
Nuxt.JS Introdruction
PPTX
An Overview on Nuxt.js
PPT
React js
PDF
Why Vue.js?
PPTX
Express js
PDF
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
PDF
Introduction à React
PDF
Introduction to React JS
Nuxt.JS Introdruction
An Overview on Nuxt.js
React js
Why Vue.js?
Express js
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Introduction à React
Introduction to React JS

What's hot (20)

PDF
introduction to Vue.js 3
PDF
Introduction to Vue.js
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PDF
react redux.pdf
PPTX
PDF
Routing in NEXTJS.pdf
PPTX
Node js Introduction
PDF
React JS and why it's awesome
PPT
Node.js Express Framework
PDF
PDF
Vue, vue router, vuex
PDF
An Introduction to ReactJS
PPTX
Express JS
PDF
Next.js Introduction
PPTX
Nodejs functions & modules
PPTX
PPTX
PPTX
NodeJS - Server Side JS
PPTX
Node.js Express
PPT
Introduction to Javascript
introduction to Vue.js 3
Introduction to Vue.js
Workshop 4: NodeJS. Express Framework & MongoDB.
react redux.pdf
Routing in NEXTJS.pdf
Node js Introduction
React JS and why it's awesome
Node.js Express Framework
Vue, vue router, vuex
An Introduction to ReactJS
Express JS
Next.js Introduction
Nodejs functions & modules
NodeJS - Server Side JS
Node.js Express
Introduction to Javascript
Ad

Viewers also liked (6)

PDF
2013 053. Retour des PTG à plateaux fixes. Pourquoi ?
PDF
University of Dammam-Inspiring a new generation of learners
PDF
5 Little Things that Can Make a Big Difference in Your Photos
PPTX
10 PowerPoint Templates That Don't Suck
PDF
Vue.js with Go
PDF
SlideShare 101
2013 053. Retour des PTG à plateaux fixes. Pourquoi ?
University of Dammam-Inspiring a new generation of learners
5 Little Things that Can Make a Big Difference in Your Photos
10 PowerPoint Templates That Don't Suck
Vue.js with Go
SlideShare 101
Ad

Similar to Nuxt.js - Introduction (20)

PDF
Love at first Vue
PPTX
Local SQLite Database with Node for beginners
PPT
nodejs tutorial foor free download from academia
PDF
Nuxtjs cheat-sheet
PPT
RESTful API In Node Js using Express
ODP
Introduce about Nodejs - duyetdev.com
PDF
NestJS
PDF
Node.js in action
PDF
Fullstack conf 2017 - Basic dev pipeline end-to-end
PDF
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
PPTX
ASP.NET vNext
PDF
Warsaw Frontend Meetup #1 - Webpack
PDF
Building and deploying React applications
PDF
Web applications with Catalyst
PPTX
Lecture: Webpack 4
PDF
Nodejs vatsal shah
PDF
Create a Full-Stack Web App with React & Node.js in 2024
PPTX
PPT
Nodejs quick start
PDF
AWS Serverless Workshop
Love at first Vue
Local SQLite Database with Node for beginners
nodejs tutorial foor free download from academia
Nuxtjs cheat-sheet
RESTful API In Node Js using Express
Introduce about Nodejs - duyetdev.com
NestJS
Node.js in action
Fullstack conf 2017 - Basic dev pipeline end-to-end
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
ASP.NET vNext
Warsaw Frontend Meetup #1 - Webpack
Building and deploying React applications
Web applications with Catalyst
Lecture: Webpack 4
Nodejs vatsal shah
Create a Full-Stack Web App with React & Node.js in 2024
Nodejs quick start
AWS Serverless Workshop

Recently uploaded (20)

PDF
The Internet -By the Numbers, Sri Lanka Edition
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PDF
Testing WebRTC applications at scale.pdf
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPTX
Digital Literacy And Online Safety on internet
PDF
WebRTC in SignalWire - troubleshooting media negotiation
The Internet -By the Numbers, Sri Lanka Edition
Slides PDF The World Game (s) Eco Economic Epochs.pdf
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
SAP Ariba Sourcing PPT for learning material
Introuction about ICD -10 and ICD-11 PPT.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
RPKI Status Update, presented by Makito Lay at IDNOG 10
Job_Card_System_Styled_lorem_ipsum_.pptx
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Testing WebRTC applications at scale.pdf
SASE Traffic Flow - ZTNA Connector-1.pdf
Sims 4 Historia para lo sims 4 para jugar
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Design_with_Watersergyerge45hrbgre4top (1).ppt
Triggering QUIC, presented by Geoff Huston at IETF 123
introduction about ICD -10 & ICD-11 ppt.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Digital Literacy And Online Safety on internet
WebRTC in SignalWire - troubleshooting media negotiation

Nuxt.js - Introduction