Next.jsに用意されているhookの1種`useRouter`を利用すれば容易に導入できるらしい [[参考]](https://zenn.dev/k_neko3/articles/893c2409f405b0)。