Repository navigation
Migrating NProgress Layout from Svelte 4 to 5 #13171
Replies: 1 comment
|
For Svelte 5 with SvelteKit 2.12.1 or newer, you can simplify this to one effect using <script lang="ts">
import type { Snippet } from 'svelte';
import { navigating } from '$app/state';
import NProgress from '$lib/utils/nprogress';
import 'nprogress/nprogress.css';
let { children }: { children: Snippet } = $props();
$effect(() => {
if (navigating.to !== null) {
NProgress.start();
} else {
NProgress.done();
}
});
</script>
{@render children()}Keep your existing The important distinction is that If you retain the legacy |
Uh oh!
There was an error while loading. Please reload this page.
We are migrating a Sveltekit project that uses Svelte 4 to Svelte 5. The root layout of this project uses nprogress to display page navigation progress status using the below code. I tried to use$effect instead of $ :, but it does not seem to work. Any ideas on what could be wrong with it?
// nprogress.ts
// Svelte 4
// Svelte 5
All reactions