Skip to content

Instantly share code, notes, and snippets.

@emailjohnthomascaballero
Last active February 6, 2024 16:51
Show Gist options
  • Save emailjohnthomascaballero/d58644e2c67335e2f04cb88af8dea781 to your computer and use it in GitHub Desktop.
Save emailjohnthomascaballero/d58644e2c67335e2f04cb88af8dea781 to your computer and use it in GitHub Desktop.
Next.js back button
{/* SOURCE LINK: https://stackoverflow.com/questions/51843119/next-js-react-go-back-to-the-previous-page */}
import { useRouter } from "next/navigation";
const Header = () => {
const router = useRouter();
return (
<div>
<button onClick={() => router.back()}>
BACK
</button>
</div>
);
};
export default Header;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment