Nuxt JS
Publish date: Mar 28, 2020
Last updated: Apr 24, 2020
Last updated: Apr 24, 2020
IMAGE GALLERY (6)
progressive framework based on Vue.js to create modern web applications. It is based on Vue.js official libraries (vue, vue-router and vuex) and powerful development tools (webpack, Babel and PostCSS).
What is NUXT?
- server side rendering SSR framework
- Understand directory structure
- Middleware -> access vuestore, fn before rendering a pages
- Pages -> router
- assets -> SASS
fetch
is replaced with Anonymous middleware
- Frontend Application
- Server side Renderign SSR vs Client side Rendering CSR
- asyncData (SSR) vs data (CSR)
- Use proxy URLs to fix CORS errors
Thing you should know
- Add router links and dynamic links
- SEO meta tags to SPA
- Page navigation transitions
- i18n localization and globalization
- Code splitting
universal
Vue based websites, meaning you can build a fully static, SEO-ready, websites using all the features of Vue.js in terms of modern user experience.asyncData
is called every time before loading the page component.- It will be called server-side once (on the first request to the Nuxt app) and client-side when navigating to further routes.
- This method receives the context as the first argument
- Nuxt axios integration
How to read/write a cookie value Add access_token from cookie to axios request as bearer Add Bearer token to axios Querystring with axios Accessing getters from modules Difference between Asyncdata vs Fetch Load data from API before page is rendered Nuxt Modules - globally available Getters with Arguments? Google Analytics Other useful Modules
Which problems does nuxt solves?
- SEO optimization for SPA, SEO friendly
- Auto route creation as of new files addition under
/pages
- standard project structure management
- can generate both static and dynamic websites with nuxt
- static
generator
- static
- Optimization for speed
npm i npx
npx create-nuxt-app <project-name>
npm install --save nuxt
yarn server --open
npm install --save-dev babel-eslint eslint eslint-config-prettier eslint-loader eslint-plugin-vue eslint-plugin-prettier prettier
npm run build
npm run generate
axios.get(`http://someurl.com/${this.$route.params.id}`, config)
- Use backticks if you want to use variables in template
How is it different from vuejs?
NUXT Framework
- SEO Advantages - custom
heads
, prebuild standard directory structurehid: description
to avoid duplicatedmeta
tags- vue-meta for supported SEO properties
- Less work managing routes
- Universal Mode
- Load the page after disabling javascript from browser
- On each route, app loades route specific JS, CSS and component (HTML) files
- Prefetching
- prefetch
js
before clicked
- prefetch
- vuex store
- return an anonymous function
NUXT Markdown Blog
Own your content and Platform
- Medium has terrible Page Perfromance
- Headless CMS - API driven CMSs
- Do you really need it? Use case?
- Vue Components inside Markdown?, like hugo shortcodes
frontmatter-markdown-loader
- How to import markdown, webpack? Else not going to work
- import(
~/content/${app.}
)
- import(
Footnotes
- https://github.com/nuxt-community/awesome-nuxt
- https://github.com/search?q=nuxt+vuetify
- https://github.com/bradtraversy/nuxt_dadjokes
- https://fabiofranchino.com/blog/how-to-create-a-nuxt-based-blog-markdown-driven-from-scratch/
- https://github.com/topics/nuxt-template
- SVG Footer in vue blog
- https://akunyi.com/category
- https://marinaaisa.com/