@xuhaojun/nextjs-navigation-lock
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

nextjs-navigation-lcok

code ship from proxyProvider to a module.

Installtion

npm install @xuhaojun/nextjs-navigation-lock

Quickstart

import { RouteChangeProvider } from "@xuhaojun/nextjs-navigation-lock";

function Page({ children }) {
  return <RouteChangeProvider>{children}</RouteChangeProvider>;
}
import {
  useNavigationLock,
  Link,
  useRouter,
} from "@xuhaojun/nextjs-navigation-lock";

function Component() {
  const [isDirty, setIsDirty] = useState(false);
  useNavigationLock(isDirty);

  const router = useRouter();
  const handleLogin = () => {
    router.push("/");
  };
  return (
    <>
      <Link href="/users">Users</Link>
      <button onClick={handleLogin}>Login</button>
    </>
  );
}

Reference

  1. Conditionally Block Navigation - nextjs - appDir

Package Sidebar

Install

npm i @xuhaojun/nextjs-navigation-lock

Weekly Downloads

3

Version

0.0.8

License

MIT

Unpacked Size

10.4 kB

Total Files

11

Last publish

Collaborators

  • xuhaojun