How do I disable Nuxt3 default loading indicator?
Asked Answered
S

2

5

I have been looking in documentation and googling for a long time and for some reason I can't seem to figure out how to disable the default Nuxt3 loading indicator. Does anyone know how to deal with this?

It only appears for a split second when I refresh page on the "/" path, so the page that displays the index.vue page. Attaching an image for reference.

image for reference

Stagey answered 15/7, 2023 at 11:40 Comment(1)
Please provide enough code so others can better understand or reproduce the problem.Vault
A
8

Try to set { spaLoadingTemplate: false } in nuxt.config.ts.

You can also create your own loading indicator.
More info here: https://nuxt.com/docs/api/configuration/nuxt-config#spaloadingtemplate

Angioma answered 15/7, 2023 at 22:41 Comment(0)
A
2

You can add your own custom loader by creating an app-loading.html in root directory of your application and adding it in the nuxt.config.ts file like this { spaLoadingTemplate: './app-loading.html' }

your app-loading.html can look like this

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="accept-ch" content="DPR" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Title</title>
  <style>
    .loader{
      position: fixed;
      inset: 0rem;
      display: grid;
      place-items: center;
      background-color: white;
      z-index: 50;
    }
    .loader__img{
      width: 4.5rem;
      animation: bounce 1s linear infinite;
    }

    @keyframes bounce {
      0%, 100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
      }
      50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
      }
    }
  </style>
</head>
<body>
  <div class="loader">
    <img src="/loader.png" class="loader__img"/>
  </div>
</body>
</html>

Antiquate answered 19/7, 2023 at 1:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.