Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-back

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-back

React Router DOM hook for navigating back without leaving your website

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60
increased by62.16%
Maintainers
1
Weekly downloads
 
Created
Source
Use Back icon

Use Back

React Router DOM hook for navigating back without leaving your website

npm version check status license: MIT

Description

A native ESModule React hook for navigating back one location using React Router DOM, defaulting to navigating home instead of leaving your web application.

Installation

npm install use-back

Note: This package is a native ESModule that requires React Router DOM v6 as a peer dependency.

Usage

import {useBack} from "use-back";

const BackButton = () => {
	const {hasBack, handleBack} = useBack();
	return (
		<button type="button" onClick={handleBack}>
			{hasBack ? "Go Back" : "Go Home"}
		</button>
	);
};

useBack([defaultPath])

Returns: {handleBack, hasBack} Object containing an event handler that navigates back, and a boolean that indicates whether the handler will navigate back or to the default path

ParameterTypeDefaultDescription
defaultPathstring"/"Fallback path to navigate to for when there is not a previous history entry

License

Copyright Evelyn Hathaway, MIT License

Keywords

FAQs

Package last updated on 21 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc