Skyleen77 / next-nprogress-bar

NProgress integration on Next.js compatible with /app and /pages folders
https://next-nprogress-bar.vercel.app
315 stars 24 forks source link

Add support for passing a custom router #73

Open ahmedriad1 opened 3 days ago

ahmedriad1 commented 3 days ago

When using a localization library, in this case next-intl, you have to use their router so that they can handle locales when changing the url.

Example:

import { createSharedPathnamesNavigation } from "next-intl/navigation";

const navigation = createSharedPathnamesNavigation({ locales: PATH_LOCALES });

// localized router
navigation.useRouter

This means there is currently no way to use next-nprogress-bar's router.

Ask

Provide a function that accepts a useRouter hook, and returns a modified version of it that supports nprogress as well.

Example:

import { makeNprogressRouter } from 'next-nprogress-bar';
import { createSharedPathnamesNavigation } from "next-intl/navigation";

const navigation = createSharedPathnamesNavigation({ locales: PATH_LOCALES });

export const useRouter = makeNprogressRouter(navigation.useRouter);