In this article, we are going to learn how loading works in Nuxt.js. Nuxt.js is a free and open-source web application framework based on Vue.js, Node.js, Webpack, and Babel.js. Nuxt is inspired by Next.js, which is a framework of a similar purpose, based on React.js.
Introduction: Adding a loading screen to Nuxt.js apps can be a great way to improve user experience. There are a few different ways to do this, but in this article, we'll focus on one method using the inbuilt functions of the Nuxt.js.
Create Nuxt.js Application:
Step 1: You can create a new Nuxt.js project using the below command:
npx create-nuxt-app gfg
Step 2: Now navigate to your app using the following command:
cd gfg
Project Structure: It will look like this.

Adding the Loading Bar: Nuxt.js provides you with a loading bar that you can use in your applications. To add the loading bar, add the below code in your index.vue file.
index.vue
<template>
<div>
<h3>This is the Home Page - GeeksforGeeks</h3>
</div>
</template>
<script>
export default {
mounted() {
this.$nextTick(() => {
this.$nuxt.$loading.start()
setTimeout(() => this.$nuxt.$loading.finish(), 2500)
})
}
}
</script>
Here we are using $nuxt.$loading.start() to start the loading bar then we are giving a time out function.
Start the application: Run the application using the below code.
npm run dev
Output:

Customizing the Loading Bar: You can customize the properties like color, size, and duration of the loading bar. For this, add the below code in the nuxt.config.js file.
nuxt.config.js
export default {
// Disable server-side rendering
ssr: true,
loading: {
color: 'green',
height: '6px'
},
// Global CSS
css: [
'view-design/dist/styles/iview.css'
],
// Plugins to run before rendering page
plugins: [
'@/plugins/view-ui',
{ src: '~/plugins/vue-datepicker', ssr: false },
{ src: '~/plugins/vue-time', ssr: false },
],
// Auto import components
components: true,
// Modules for dev and build (recommended)
buildModules: [
],
// Modules
modules: [
],
// Build Configuration
build: {
}
}
Start the application: Run the application using the below code.
npm run dev
Output:

Similar Reads
loading.js in Next JS Next JS is a React framework that provides a number of features to help you build fast and scalable web applications. One of these features is loading.js which allows you to create a loading UI for your application.Prerequisites:JavaScript/TypeScriptReactJS BasicsNextJSLoading UI is important becaus
3 min read
Lazy Loading in Next.js Lazy loading in NextJS is a technique used to improve the performance and loading times of web applications built with the NextJS framework. With lazy loading, components or modules are loaded only when they are needed, rather than upfront when the page is initially rendered. This means that resourc
4 min read
p5.js loadStrings() Function The loadStrings() function is used to read the contents of a file and create an array of strings with each of the lines of the file. The file to be read must be located at the sketch directory if the file name is used, otherwise, a URL to the file can be specified. This function is recommended to be
2 min read
Meta Tags in Nuxt.js In this article, we are going to learn how meta tags and SEO work in NuxtJs. Nuxt.js is a free and open-source web application framework based on Vue.js, Node.js, Webpack, and Babel.js. Nuxt is inspired by Next.js, which is a framework of a similar purpose, based on React.js.Create NuxtJS Applicatio
3 min read
How to add Loading Quotes in Next.js ? In this article, we are going to learn how we can add loading quotes in NextJs. NextJS is a React-based framework. It has the power to Develop beautiful Web applications for different platforms like Windows, Linux, and mac. The linking of dynamic paths helps in rendering your NextJS components condi
2 min read