Skip to content

Instantly share code, notes, and snippets.

@jide
Created January 11, 2024 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jide/308e2aaabfb1c3c6855819f8372d3644 to your computer and use it in GitHub Desktop.
Save jide/308e2aaabfb1c3c6855819f8372d3644 to your computer and use it in GitHub Desktop.
Auto reload for Next.js
"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