Skip to content

@atomico/use-router@1.1.0

Compare
Choose a tag to compare
@UpperCod UpperCod released this 21 May 19:57
· 3 commits to master since this release

@atomico/use-router@1.1.0

Now this hook is simpler, it only exposes the following utilities as a module:

  1. useRouter: hook for routing
  2. redirect: callback for redirecting
  3. getPath: callback for getting the path from useRouter

Example of useRouter

const { id, result, path, params, redirect } = useRouter<string>({
	"/": () => "home",
	"/config": () => "config",
});
  1. id: path from location.
  2. result: return of the callback.
  3. params: parameters of the callback.
  4. redirect: equivalent to redirect from the module.