Skip to content

seito2/nextjs-custom-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nextjs custom router

You can set the conditions under which the nextjs router event will be executed.

Install

npm install nextjs-custom-router

Usage

import { useCustomRouter } from "nextjs-custom-router";


export const Component = () => {
  const router = useCustomRouter(
    (router) => {
      // Write your condition for cancel router event.
    },
    (router) => {
      // This is optional, you can run callback before cancel router event.
    }
  );

  const handleOnClick = () => {
    router.push('/other-place')
  }

  return (
    <div>
      <button onClick={handleOnClick}>Move</button>
    </div>
  );
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published