Nprogress
sveltekit
Install nprogress
terminal
npm i nprogress
- Import Nprogress in +layout.svelte & also nprogress.css to style the bar+layout.svelte
import NProgress from 'nprogress'; import 'nprogress/nprogress.css';
- Now import beforeNavigate and afterNavigate+layout.svelte
import { afterNavigate, beforeNavigate, goto } from '$app/navigation';
- Create beforeNavigate and afterNavigate functions.+layout.svelte
beforeNavigate(async () => { NProgress.start(); }); afterNavigate(async () => { NProgress.done(); });
- If we don’t want the loading circle we can configure Nprogress+layout.svelte
NProgress.configure({ showSpinner: false });
- To change style or color, add code to app.postcssapp.postcss
#nprogress .bar { background: rgb(221, 34, 40) !important; height: 2px !important; }