[{"data":1,"prerenderedAt":163},["ShallowReactive",2],{"blog-tag-vue":3,"blog-tag-posts-vue":32},{"id":4,"count":5,"description":6,"link":7,"name":8,"slug":8,"taxonomy":9,"meta":10,"_links":11},32,2,"","https:\u002F\u002Flab.aiarnob.com\u002Ftag\u002Fvue\u002F","vue","post_tag",[],{"self":12,"collection":18,"about":21,"wp:post_type":24,"curies":27},[13],{"href":14,"targetHints":15},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftags\u002F32",{"allow":16},[17],"GET",[19],{"href":20},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftags",[22],{"href":23},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftaxonomies\u002Fpost_tag",[25],{"href":26},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts?tags=32",[28],{"name":29,"href":30,"templated":31},"wp","https:\u002F\u002Fapi.w.org\u002F{rel}",true,[33,108],{"id":34,"date":35,"date_gmt":35,"guid":36,"modified":35,"modified_gmt":35,"slug":38,"status":39,"type":40,"link":37,"title":41,"content":43,"excerpt":46,"author":48,"featured_media":49,"comment_status":50,"ping_status":50,"sticky":45,"template":6,"format":51,"meta":52,"categories":53,"tags":54,"class_list":56,"post_image_original":66,"devto_meta":67,"_links":72},52,"2021-06-12T06:23:56",{"rendered":37},"https:\u002F\u002Flab.aiarnob.com\u002Fnuxt-js-data-fetching-hook-async-data\u002F","nuxt-js-data-fetching-hook-async-data","publish","post",{"rendered":42},"Nuxt.js Data Fetching Hook: Async Data.",{"rendered":44,"protected":45},"\u003Cp>In this blog, I am discussing the Nuxt.js asyncData hook. For server-side rendering in Nuxt.js need to use specific hooks. This allows your page to render with all of its required data presents.\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"nuxtjs-has-two-hooks-for-asynchronous-data-loading\" href=\"#nuxtjs-has-two-hooks-for-asynchronous-data-loading\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Nuxt.js has two hooks for asynchronous data loading:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Col>\n\u003Cli>The fetch hook\u003C\u002Fli>\n\u003Cli>The asyncData hook\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>Also, Nuxt.js supports traditional Vue patterns for loading data in your client-side app, such as fetching data in a component&#8217;s \u003Cstrong>mounted()\u003C\u002Fstrong> hook.\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"some-important-features-of-asyncdata-hook-in-nuxtjs\" href=\"#some-important-features-of-asyncdata-hook-in-nuxtjs\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Some important features of asyncData hook in Nuxt.js:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Col>\n\u003Cli>asyncData works on both server-side &amp; client-side rendering.\u003C\u002Fli>\n\u003Cli>asyncData is called every time before loading a component.\u003C\u002Fli>\n\u003Cli>You can use only on next pages, not in vue components.\u003C\u002Fli>\n\u003Cli>anyncData is called from the server-side before the component is mounted. That’s why you don’t have access to \u003Cstrong>’this’\u003C\u002Fstrong> keyword inside \u003Cstrong>asyncData()\u003C\u002Fstrong>.\u003C\u002Fli>\n\u003Cli>This method receives the \u003Ca href=\"https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Fconcepts\u002Fcontext-helpers\" target=\"_blank\" rel=\"noopener noreferrer\">context\u003C\u002Fa> object as the first argument and you can use it to access core nuxt properties such as route, store, params, app, etc.\u003C\u002Fli>\n\u003Cli>The result from asyncData will be merged with data.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>\u003Cstrong>Here is the example of nuxt asyncData using \u003Ca href=\"https:\u002F\u002Faxios.nuxtjs.org\u002F\" target=\"_blank\" rel=\"noopener noreferrer\">@nuxt\u002Faxios\u003C\u002Fa> library:\u003C\u002Fstrong>\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">template\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">div\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n    \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">h1\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\u003Cspan class=\"p\">{{\u003C\u002Fspan> \u003Cspan class=\"nx\">post\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">title\u003C\u002Fspan> \u003Cspan class=\"p\">}}\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fh1\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>    \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">p\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\u003Cspan class=\"p\">{{\u003C\u002Fspan> \u003Cspan class=\"nx\">post\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">description\u003C\u002Fspan> \u003Cspan class=\"p\">}}\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fp\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>  \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fdiv\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Ftemplate\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">script\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"k\">async\u003C\u002Fspan> \u003Cspan class=\"nf\">asyncData\u003C\u002Fspan>\u003Cspan class=\"p\">({\u003C\u002Fspan>\u003Cspan class=\"nx\">params\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan> \u003Cspan class=\"nx\">$axios\u003C\u002Fspan> \u003Cspan class=\"p\">})\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n      \u003Cspan class=\"kd\">const\u003C\u002Fspan> \u003Cspan class=\"nx\">post\u003C\u002Fspan> \u003Cspan class=\"o\">=\u003C\u002Fspan> \u003Cspan class=\"k\">await\u003C\u002Fspan> \u003Cspan class=\"nx\">$http\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nf\">$get\u003C\u002Fspan>\u003Cspan class=\"p\">(\u003C\u002Fspan>\u003Cspan class=\"s2\">`https:\u002F\u002Fapi.nuxtjs.dev\u002Fposts\u002F\u003C\u002Fspan>\u003Cspan class=\"p\">${\u003C\u002Fspan>\u003Cspan class=\"nx\">params\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">id\u003C\u002Fspan>\u003Cspan class=\"p\">}\u003C\u002Fspan>\u003Cspan class=\"s2\">`\u003C\u002Fspan>\u003Cspan class=\"p\">)\u003C\u002Fspan>\n      \u003Cspan class=\"k\">return\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan> \u003Cspan class=\"nx\">post\u003C\u002Fspan> \u003Cspan class=\"p\">}\u003C\u002Fspan>\n    \u003Cspan class=\"p\">}\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fscript\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>asyncData hook returned the promise and resolved during the route transition. This means that no &#8220;loading placeholder&#8221; is visible during client-side transitions but you can use the \u003Ca href=\"https:\u002F\u002Fdev.to\u002Faiarnob\u002Fhow-to-use-nuxt-js-loading-progress-bar-39l3\">loading bar\u003C\u002Fa> can be used to indicate a loading state to the user.\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"asyncdata-on-both-clientside-amp-serverside\" href=\"#asyncdata-on-both-clientside-amp-serverside\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  asyncData() on both client-side &amp; server-side:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cp>To test how asyncData() works on both client-side &amp; server-side, please write the bellow code on your Nuxt.js page.\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight plaintext\">\u003Ccode>&lt;script&gt;\nexport default{\n    asyncData(context){\n        console.log(context);\n}\n}\n&lt;\u002Fscript&gt;\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>\u003Cstrong>Server Side Test\u003C\u002Fstrong>\u003Cbr \u002F>\nNow reload the page on the browser and look inside your terminal(also can check on browser console panel Nuxt SSR Response) on which your Nuxt.js application running. You can see the context object like the below screenshot. That means its works on the server-side.\u003Cbr \u002F>\n\u003Ca href=\"https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzjzudyqv04q4wdcdck1.png\" class=\"article-body-image-wrapper\">\u003Cimg decoding=\"async\" src=\"https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzjzudyqv04q4wdcdck1.png\" alt=\"Nuxt.js SSR\" loading=\"lazy\" width=\"800\" height=\"667\">\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Client Side Test\u003C\u002Fstrong>\u003Cbr \u002F>\nYou can also check client-side rendering when you come to this page from another Nuxt.js page (The link must be used NuxtLink for linking between pages). Now open your browser dev tools and check the console panel and you see the magic of asyncData().\u003Cbr \u002F>\n\u003Ca href=\"https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe6rcmn858p4sej707em.png\" class=\"article-body-image-wrapper\">\u003Cimg decoding=\"async\" src=\"https:\u002F\u002Fmedia2.dev.to\u002Fdynamic\u002Fimage\u002Fwidth=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\u002Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe6rcmn858p4sej707em.png\" alt=\"Client Side Test Nuxt.js\" loading=\"lazy\" width=\"800\" height=\"247\">\u003C\u002Fa>\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"how-you-can-use-async-data-in-components\" href=\"#how-you-can-use-async-data-in-components\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  How you can use Async data in components:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cp>We already know that we can not use anyncData hook inside any component but we can use another way for component. \u003Cbr \u002F>\nMake the API call in the asyncData method of the page component and pass the data as props to the sub components. Both Client &amp; Server side rendering will work fine.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Referance:\u003C\u002Fstrong> Nuxt.js Official Data Fetch \u003Ca href=\"https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Ffeatures\u002Fdata-fetching\" target=\"_blank\" rel=\"noopener noreferrer\">Hook\u003C\u002Fa>\u003C\u002Fp>\n",false,{"rendered":47,"protected":45},"\u003Cp>In this blog, I am discussing the Nuxt.js asyncData hook. For server-side rendering in Nuxt.js need&#8230;\u003C\u002Fp>\n",1,53,"open","standard",{"footnotes":6},[48],[55,4],25,[57,40,58,59,60,61,62,63,64,65],"post-52","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-javascript","tag-vue","https:\u002F\u002Flab.aiarnob.com\u002Fwp-content\u002Fuploads\u002F2021\u002F06\u002Fdevto-726068-cover.webp",{"edited_at":68,"published_at":69,"reactions":70,"comments":5,"reading_time":5,"body_markdown":71},"2021-06-12T09:06:19Z","2021-06-12T06:23:56Z",15,"In this blog, I am discussing the Nuxt.js asyncData hook. For server-side rendering in Nuxt.js need to use specific hooks. This allows your page to render with all of its required data presents.\n\n##Nuxt.js has two hooks for asynchronous data loading:\n1. The fetch hook\n2. The asyncData hook\n\nAlso, Nuxt.js supports traditional Vue patterns for loading data in your client-side app, such as fetching data in a component's **mounted()** hook.\n\n##Some important features of asyncData hook in Nuxt.js:\n1. asyncData works on both server-side & client-side rendering.\n2. asyncData is called every time before loading a component.\n3. You can use only on next pages, not in vue components.\n4. anyncData is called from the server-side before the component is mounted. That’s why you don’t have access to **’this’** keyword inside **asyncData()**.\n5. This method receives the [context](https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Fconcepts\u002Fcontext-helpers) object as the first argument and you can use it to access core nuxt properties such as route, store, params, app, etc.\n6. The result from asyncData will be merged with data.\n\n**Here is the example of nuxt asyncData using [@nuxt\u002Faxios](https:\u002F\u002Faxios.nuxtjs.org\u002F) library:**\n``` javascript\n\u003Ctemplate>\n  \u003Cdiv>\n    \u003Ch1>{{ post.title }}\u003C\u002Fh1>\n    \u003Cp>{{ post.description }}\u003C\u002Fp>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n\n\u003Cscript>\n  export default {\n    async asyncData({params, $axios }) {\n      const post = await $http.$get(`https:\u002F\u002Fapi.nuxtjs.dev\u002Fposts\u002F${params.id}`)\n      return { post }\n    }\n  }\n\u003C\u002Fscript>\n```\n\nasyncData hook returned the promise and resolved during the route transition. This means that no \"loading placeholder\" is visible during client-side transitions but you can use the [loading bar](https:\u002F\u002Fdev.to\u002Faiarnob\u002Fhow-to-use-nuxt-js-loading-progress-bar-39l3) can be used to indicate a loading state to the user.\n\n##asyncData() on both client-side & server-side:\nTo test how asyncData() works on both client-side & server-side, please write the bellow code on your Nuxt.js page.\n```\n\u003Cscript>\nexport default{\n\tasyncData(context){\n\t\tconsole.log(context);\n}\n}\n\u003C\u002Fscript>\n```\n\n**Server Side Test**\nNow reload the page on the browser and look inside your terminal(also can check on browser console panel Nuxt SSR Response) on which your Nuxt.js application running. You can see the context object like the below screenshot. That means its works on the server-side.\n![Nuxt.js SSR](https:\u002F\u002Fdev-to-uploads.s3.amazonaws.com\u002Fuploads\u002Farticles\u002Fwzjzudyqv04q4wdcdck1.png)\n\n**Client Side Test**\nYou can also check client-side rendering when you come to this page from another Nuxt.js page (The link must be used NuxtLink for linking between pages). Now open your browser dev tools and check the console panel and you see the magic of asyncData().\n![Client Side Test Nuxt.js](https:\u002F\u002Fdev-to-uploads.s3.amazonaws.com\u002Fuploads\u002Farticles\u002Foe6rcmn858p4sej707em.png)\n\n##How you can use Async data in components:\nWe already know that we can not use anyncData hook inside any component but we can use another way for component. \nMake the API call in the asyncData method of the page component and pass the data as props to the sub components. Both Client & Server side rendering will work fine.\n\n**Referance:** Nuxt.js Official Data Fetch [Hook](https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Ffeatures\u002Fdata-fetching)",{"self":73,"collection":78,"about":81,"author":84,"replies":87,"version-history":90,"wp:featuredmedia":94,"wp:attachment":97,"wp:term":100,"curies":106},[74],{"href":75,"targetHints":76},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts\u002F52",{"allow":77},[17],[79],{"href":80},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts",[82],{"href":83},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftypes\u002Fpost",[85],{"embeddable":31,"href":86},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fusers\u002F1",[88],{"embeddable":31,"href":89},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fcomments?post=52",[91],{"count":92,"href":93},0,"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts\u002F52\u002Frevisions",[95],{"embeddable":31,"href":96},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fmedia\u002F53",[98],{"href":99},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fmedia?parent=52",[101,104],{"taxonomy":102,"embeddable":31,"href":103},"category","https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fcategories?post=52",{"taxonomy":9,"embeddable":31,"href":105},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftags?post=52",[107],{"name":29,"href":30,"templated":31},{"id":109,"date":110,"date_gmt":110,"guid":111,"modified":110,"modified_gmt":110,"slug":113,"status":39,"type":40,"link":112,"title":114,"content":116,"excerpt":118,"author":48,"featured_media":120,"comment_status":50,"ping_status":50,"sticky":45,"template":6,"format":51,"meta":121,"categories":122,"tags":123,"class_list":124,"post_image_original":126,"devto_meta":127,"_links":132},54,"2021-05-31T09:31:46",{"rendered":112},"https:\u002F\u002Flab.aiarnob.com\u002Fhow-to-use-nuxt-js-loading-progress-bar\u002F","how-to-use-nuxt-js-loading-progress-bar",{"rendered":115},"How to Use Nuxt.js Loading Progress Bar",{"rendered":117,"protected":45},"\u003Cp>Are you using Nuxt.js on your current project as front-end framework? then you have a great news, Nuxt.js Out of the box gives you its own loading progress bar component that&#8217;s shown between routes. You can do anything with the Nuxt.js loading progress bar, customize it, disable it, or can create your own \u003Cstrong>loading\u003C\u002Fstrong> progress bar.\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"active-amp-customize-progress-bar\" href=\"#active-amp-customize-progress-bar\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Active &amp; Customize Progress Bar:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cp>You can activate the progress bar on your Nuxt.js application by adding the \u003Cstrong>loading\u003C\u002Fstrong> property of the \u003Cstrong>nuxt.config.js\u003C\u002Fstrong> inside the \u003Ccode>export default { \u002F\u002Fcode here }\u003C\u002Fcode> with the corresponding properties.\u003C\u002Fp>\n\u003Cp>To set a green progress bar with a height of 5px, add the following code inside your project \u003Cstrong>nuxt.config.js\u003C\u002Fstrong> file.\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n  \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"na\">color\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"s1\">green\u003C\u002Fspan>\u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">height\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"s1\">5px\u003C\u002Fspan>\u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">throttle\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">0\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>You can customize many things, you can change color(color name\u002Fcolor hex code), height, duration, direction for \u003Cstrong>rtl\u003C\u002Fstrong> sites, keep animating progress bar when loading takes longer than duration.\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n  \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"na\">color\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"s1\">green\u003C\u002Fspan>\u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">height\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"s1\">5px\u003C\u002Fspan>\u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">duration\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">1000\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">rtl\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"kc\">true\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan>\n    \u003Cspan class=\"na\">continuous\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"kc\">true\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Ch2>\n  \u003Ca name=\"disable-the-progress-bar\" href=\"#disable-the-progress-bar\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Disable the Progress Bar:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cp>You can disable the progress bar globally or locally. If you want to disable the progress bar globally then add \u003Cstrong>loading: false\u003C\u002Fstrong> in your \u003Cstrong>nuxt.config.js\u003C\u002Fstrong> file:\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n  \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"kc\">false\u003C\u002Fspan>\n\u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>Your can also disable the progress bar for specific page.  Add \u003Cstrong>loading: false\u003C\u002Fstrong> in the specific page.\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">template\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">h1\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\u003Cspan class=\"nx\">Contact\u003C\u002Fspan> \u003Cspan class=\"nx\">Us\u003C\u002Fspan> \u003Cspan class=\"nx\">Page\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fh1\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Ftemplate\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">script\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"kc\">false\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fscript\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Ch2>\n  \u003Ca name=\"custom-loading-progress-bar\" href=\"#custom-loading-progress-bar\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Custom Loading Progress Bar:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cp>You can also create your own custom loading progress bar. Inside the component directory create your custom component in \u003Cstrong>LoadingBar.vue\u003C\u002Fstrong>:\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">template\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">div\u003C\u002Fspan> \u003Cspan class=\"nx\">v\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"k\">if\u003C\u002Fspan>\u003Cspan class=\"o\">=\u003C\u002Fspan>\u003Cspan class=\"dl\">\"\u003C\u002Fspan>\u003Cspan class=\"s2\">loading\u003C\u002Fspan>\u003Cspan class=\"dl\">\"\u003C\u002Fspan> \u003Cspan class=\"kd\">class\u003C\u002Fspan>\u003Cspan class=\"o\">=\u003C\u002Fspan>\u003Cspan class=\"dl\">\"\u003C\u002Fspan>\u003Cspan class=\"s2\">loading-page\u003C\u002Fspan>\u003Cspan class=\"dl\">\"\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n    \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">p\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\u003Cspan class=\"nx\">Loading\u003C\u002Fspan>\u003Cspan class=\"p\">...\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fp\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>  \u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fdiv\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Ftemplate\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">script\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"na\">data\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"p\">()\u003C\u002Fspan> \u003Cspan class=\"o\">=&gt;\u003C\u002Fspan> \u003Cspan class=\"p\">({\u003C\u002Fspan>\n      \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"kc\">false\u003C\u002Fspan>\n    \u003Cspan class=\"p\">}),\u003C\u002Fspan>\n    \u003Cspan class=\"na\">methods\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n      \u003Cspan class=\"nf\">start\u003C\u002Fspan>\u003Cspan class=\"p\">()\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n        \u003Cspan class=\"k\">this\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">loading\u003C\u002Fspan> \u003Cspan class=\"o\">=\u003C\u002Fspan> \u003Cspan class=\"kc\">true\u003C\u002Fspan>\n      \u003Cspan class=\"p\">},\u003C\u002Fspan>\n      \u003Cspan class=\"nf\">finish\u003C\u002Fspan>\u003Cspan class=\"p\">()\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n        \u003Cspan class=\"k\">this\u003C\u002Fspan>\u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">loading\u003C\u002Fspan> \u003Cspan class=\"o\">=\u003C\u002Fspan> \u003Cspan class=\"kc\">false\u003C\u002Fspan>\n      \u003Cspan class=\"p\">}\u003C\u002Fspan>\n    \u003Cspan class=\"p\">}\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fscript\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"nx\">style\u003C\u002Fspan> \u003Cspan class=\"nx\">scoped\u003C\u002Fspan>\u003Cspan class=\"o\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"p\">.\u003C\u002Fspan>\u003Cspan class=\"nx\">loading\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">page\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">position\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"nx\">fixed\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">top\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">0\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">left\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">0\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">width\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">100\u003C\u002Fspan>\u003Cspan class=\"o\">%\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">height\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">100\u003C\u002Fspan>\u003Cspan class=\"o\">%\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nl\">background\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"nf\">rgba\u003C\u002Fspan>\u003Cspan class=\"p\">(\u003C\u002Fspan>\u003Cspan class=\"mi\">255\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan> \u003Cspan class=\"mi\">255\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan> \u003Cspan class=\"mi\">255\u003C\u002Fspan>\u003Cspan class=\"p\">,\u003C\u002Fspan> \u003Cspan class=\"mf\">0.8\u003C\u002Fspan>\u003Cspan class=\"p\">);\u003C\u002Fspan>\n    \u003Cspan class=\"nx\">text\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">align\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"nx\">center\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nx\">padding\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">top\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">200\u003C\u002Fspan>\u003Cspan class=\"nx\">px\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nx\">font\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">size\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"mi\">30\u003C\u002Fspan>\u003Cspan class=\"nx\">px\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n    \u003Cspan class=\"nx\">font\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">family\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"nx\">sans\u003C\u002Fspan>\u003Cspan class=\"o\">-\u003C\u002Fspan>\u003Cspan class=\"nx\">serif\u003C\u002Fspan>\u003Cspan class=\"p\">;\u003C\u002Fspan>\n  \u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003Cspan class=\"o\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sr\">\u002Fstyle\u003C\u002Fspan>\u003Cspan class=\"err\">&gt;\n\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>Then go to \u003Cstrong>nuxt.config.js\u003C\u002Fstrong> file and add your custom loading component to the \u003Cstrong>loading\u003C\u002Fstrong> property.\n\u003C\u002Fp>\n\u003Cdiv class=\"highlight js-code-highlight\">\n\u003Cpre class=\"highlight javascript\">\u003Ccode>\u003Cspan class=\"k\">export\u003C\u002Fspan> \u003Cspan class=\"k\">default\u003C\u002Fspan> \u003Cspan class=\"p\">{\u003C\u002Fspan>\n  \u003Cspan class=\"na\">loading\u003C\u002Fspan>\u003Cspan class=\"p\">:\u003C\u002Fspan> \u003Cspan class=\"dl\">'\u003C\u002Fspan>\u003Cspan class=\"s1\">~\u002Fcomponents\u002FLoadingBar.vue\u003C\u002Fspan>\u003Cspan class=\"dl\">'\u003C\u002Fspan>\n\u003Cspan class=\"p\">}\u003C\u002Fspan>\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cdiv class=\"highlight__panel js-actions-panel\">\n\u003Cdiv class=\"highlight__panel-action js-fullscreen-code-action\">\n    \u003Ctitle>Enter fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003Cp>    \u003Ctitle>Exit fullscreen mode\u003C\u002Ftitle>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cp>It’s very simple, right? Now you can see your own custom loading bar between routes changing.\u003C\u002Fp>\n\u003Ch2>\n  \u003Ca name=\"useful-links\" href=\"#useful-links\">\u003Cbr \u002F>\n  \u003C\u002Fa>\u003Cbr \u002F>\n  Useful Links:\u003Cbr \u002F>\n\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>Nuxt \u003Ca href=\"https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Ffeatures\u002Floading\" target=\"_blank\" rel=\"noopener noreferrer\">Loading Docs.\u003C\u002Fa>\n\u003C\u002Fli>\n\u003Cli>Custom loading component \u003Ca href=\"https:\u002F\u002Fnuxtjs.org\u002Fexamples\u002Fcustom-loading-component\" target=\"_blank\" rel=\"noopener noreferrer\">example.\u003C\u002Fa>\n\u003C\u002Fli>\n\u003C\u002Ful>\n",{"rendered":119,"protected":45},"\u003Cp>Are you using Nuxt.js on your current project as front-end framework? then you have a great news, Nux&#8230;\u003C\u002Fp>\n",55,{"footnotes":6},[48],[55,4],[125,40,58,59,60,61,62,63,64,65],"post-54","https:\u002F\u002Flab.aiarnob.com\u002Fwp-content\u002Fuploads\u002F2021\u002F05\u002Fdevto-713175-cover.webp",{"edited_at":128,"published_at":129,"reactions":130,"comments":48,"reading_time":5,"body_markdown":131},null,"2021-05-31T09:31:46Z",8,"Are you using Nuxt.js on your current project as front-end framework? then you have a great news, Nuxt.js Out of the box gives you its own loading progress bar component that's shown between routes. You can do anything with the Nuxt.js loading progress bar, customize it, disable it, or can create your own **loading** progress bar.\n\n## Active & Customize Progress Bar:\nYou can activate the progress bar on your Nuxt.js application by adding the **loading** property of the **nuxt.config.js** inside the `export default { \u002F\u002Fcode here }` with the corresponding properties.\n\nTo set a green progress bar with a height of 5px, add the following code inside your project **nuxt.config.js** file.\n\n```javascript\nexport default {\n  loading: {\n    color: 'green',\n    height: '5px',\n    throttle: 0\n  }\n}\n```\nYou can customize many things, you can change color(color name\u002Fcolor hex code), height, duration, direction for **rtl** sites, keep animating progress bar when loading takes longer than duration.\n\n```javascript\nexport default {\n  loading: {\n    color: 'green',\n    height: '5px',\n    duration: 1000,\n    rtl: true,\n    continuous: true\n  }\n}\n```\n\n## Disable the Progress Bar:\nYou can disable the progress bar globally or locally. If you want to disable the progress bar globally then add **loading: false** in your **nuxt.config.js** file:\n```javascript\nexport default {\n  loading: false\n}\n```\n\nYour can also disable the progress bar for specific page.  Add **loading: false** in the specific page.\n```javascript\n\u003Ctemplate>\n  \u003Ch1>Contact Us Page\u003C\u002Fh1>\n\u003C\u002Ftemplate>\n\n\u003Cscript>\n  export default {\n    loading: false\n  }\n\u003C\u002Fscript>\n```\n\n##Custom Loading Progress Bar:\nYou can also create your own custom loading progress bar. Inside the component directory create your custom component in **LoadingBar.vue**:\n```javascript\n\u003Ctemplate>\n  \u003Cdiv v-if=\"loading\" class=\"loading-page\">\n    \u003Cp>Loading...\u003C\u002Fp>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n\n\u003Cscript>\n  export default {\n    data: () => ({\n      loading: false\n    }),\n    methods: {\n      start() {\n        this.loading = true\n      },\n      finish() {\n        this.loading = false\n      }\n    }\n  }\n\u003C\u002Fscript>\n\n\u003Cstyle scoped>\n  .loading-page {\n    position: fixed;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    background: rgba(255, 255, 255, 0.8);\n    text-align: center;\n    padding-top: 200px;\n    font-size: 30px;\n    font-family: sans-serif;\n  }\n\u003C\u002Fstyle>\n```\n\nThen go to **nuxt.config.js** file and add your custom loading component to the **loading** property.\n```javascript\nexport default {\n  loading: '~\u002Fcomponents\u002FLoadingBar.vue'\n}\n```\nIt’s very simple, right? Now you can see your own custom loading bar between routes changing.\n\n##Useful Links:\n* Nuxt [Loading Docs.](https:\u002F\u002Fnuxtjs.org\u002Fdocs\u002F2.x\u002Ffeatures\u002Floading)\n* Custom loading component [example.](https:\u002F\u002Fnuxtjs.org\u002Fexamples\u002Fcustom-loading-component)",{"self":133,"collection":138,"about":140,"author":142,"replies":144,"version-history":147,"wp:featuredmedia":150,"wp:attachment":153,"wp:term":156,"curies":161},[134],{"href":135,"targetHints":136},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts\u002F54",{"allow":137},[17],[139],{"href":80},[141],{"href":83},[143],{"embeddable":31,"href":86},[145],{"embeddable":31,"href":146},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fcomments?post=54",[148],{"count":92,"href":149},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fposts\u002F54\u002Frevisions",[151],{"embeddable":31,"href":152},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fmedia\u002F55",[154],{"href":155},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fmedia?parent=54",[157,159],{"taxonomy":102,"embeddable":31,"href":158},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Fcategories?post=54",{"taxonomy":9,"embeddable":31,"href":160},"https:\u002F\u002Flab.aiarnob.com\u002Fwp-json\u002Fwp\u002Fv2\u002Ftags?post=54",[162],{"name":29,"href":30,"templated":31},1781010869250]