Created
January 11, 2024 15:57
-
-
Save jide/308e2aaabfb1c3c6855819f8372d3644 to your computer and use it in GitHub Desktop.
Auto reload for Next.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import useInterval from "use-interval"; | |
import { useRouter } from "next/navigation"; | |
export function AutoReload({ delay = 1000 }) { | |
const router = useRouter(); | |
useInterval(() => { | |
router.refresh(); | |
}, delay); | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment