{"id":16875945,"url":"https://github.com/evelynhathaway/use-back","last_synced_at":"2025-04-11T11:32:28.597Z","repository":{"id":38173606,"uuid":"369058087","full_name":"evelynhathaway/use-back","owner":"evelynhathaway","description":"👈✨ React Router DOM hook for navigating back without leaving your website","archived":false,"fork":false,"pushed_at":"2022-08-21T18:44:54.000Z","size":409,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T11:27:09.156Z","etag":null,"topics":["esmodules","history","hooks","react","react-router"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/use-back","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evelynhathaway.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-20T02:36:34.000Z","updated_at":"2023-03-15T17:17:09.000Z","dependencies_parsed_at":"2022-09-02T11:32:29.185Z","dependency_job_id":null,"html_url":"https://github.com/evelynhathaway/use-back","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evelynhathaway%2Fuse-back","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evelynhathaway%2Fuse-back/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evelynhathaway%2Fuse-back/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evelynhathaway%2Fuse-back/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evelynhathaway","download_url":"https://codeload.github.com/evelynhathaway/use-back/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248384087,"owners_count":21094670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esmodules","history","hooks","react","react-router"],"created_at":"2024-10-13T15:37:38.611Z","updated_at":"2025-04-11T11:32:28.569Z","avatar_url":"https://github.com/evelynhathaway.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg alt=\"Use Back icon\" width=\"128\" height=\"128\" align=\"center\" src=\".github/icon.png\"/\u003e\n\n# Use Back\n\n**React Router DOM hook for navigating back without leaving your website**\n\n[![npm version](https://badgen.net/npm/v/use-back?icon=npm)](https://www.npmjs.com/package/use-back)\n[![check status](https://badgen.net/github/checks/evelynhathaway/use-back/main?icon=github)](https://github.com/evelynhathaway/use-back/actions)\n[![license: MIT](https://badgen.net/badge/license/MIT/blue)](/LICENSE)\n\n\u003c/div\u003e\n\n## Description\n\nA native ESModule React hook for navigating back one location using React Router DOM, defaulting to navigating home instead of leaving your web application.\n\n## Installation\n\n```bash\nnpm install use-back\n```\n\n**Note:** This package is a native ESModule that requires React Router DOM v6 as a peer dependency.\n\n## Usage\n\n```tsx\nimport {useBack} from \"use-back\";\n\nconst BackButton = () =\u003e {\n\tconst {hasBack, handleBack} = useBack();\n\treturn (\n\t\t\u003cbutton type=\"button\" onClick={handleBack}\u003e\n\t\t\t{hasBack ? \"Go Back\" : \"Go Home\"}\n\t\t\u003c/button\u003e\n\t);\n};\n```\n\n### `useBack([defaultPath])`\n\n**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\n\n| Parameter   | Type     | Default | Description                                                                 |\n| ----------- | -------- | ------- | --------------------------------------------------------------------------- |\n| defaultPath | `string` | `\"/\"`   | Fallback path to navigate to for when there is not a previous history entry |\n\n## License\n\nCopyright Evelyn Hathaway, [MIT License](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevelynhathaway%2Fuse-back","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevelynhathaway%2Fuse-back","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevelynhathaway%2Fuse-back/lists"}