{"id":17673847,"url":"https://github.com/pshrmn/hickory","last_synced_at":"2025-04-28T15:50:27.469Z","repository":{"id":40827513,"uuid":"94738678","full_name":"pshrmn/hickory","owner":"pshrmn","description":"History management for single page applications. Powers https://curi.js.org","archived":false,"fork":false,"pushed_at":"2023-01-04T12:58:19.000Z","size":4206,"stargazers_count":24,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T02:43:56.973Z","etag":null,"topics":["history","javascript","single-page-app"],"latest_commit_sha":null,"homepage":"","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/pshrmn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-06-19T05:10:50.000Z","updated_at":"2024-05-02T10:23:26.000Z","dependencies_parsed_at":"2023-02-02T13:17:15.792Z","dependency_job_id":null,"html_url":"https://github.com/pshrmn/hickory","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshrmn%2Fhickory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshrmn%2Fhickory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshrmn%2Fhickory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pshrmn%2Fhickory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pshrmn","download_url":"https://codeload.github.com/pshrmn/hickory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302782,"owners_count":21567601,"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":["history","javascript","single-page-app"],"created_at":"2024-10-24T06:05:48.137Z","updated_at":"2025-04-28T15:50:27.450Z","avatar_url":"https://github.com/pshrmn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hickory\n\n[![npm][version-badge]][npm-hickory] [![Travis][build-badge]][build] [![BrowserStack Status][browserstack-badge]][browserstack-build]\n\nA single page application navigation system that works in the browser or in memory.\n\n### Documentation\n\nYou can learn about Hickory and read up on the APIs in the [documentation](./docs)\n\n### Inspiration\n\nHickory is heavily inspired by the [history](https://github.com/ReactTraining/history) package and the `history` modules from [`vue-router`](https://github.com/vuejs/vue-router).\n\n### Packages\n\nThis repository is a monorepo for the Hickory packages. Unless you are creating your own customized history type, you only need to know about three of them:\n\n| Package   | Version                                          | Repo                                       | API                            |\n| --------- | ------------------------------------------------ | ------------------------------------------ | ------------------------------ |\n| browser   | [![npm][browser-version-badge]][npm-browser]     | [packages/browser](./packages/browser)     | [API](./docs/api/browser.md)   |\n| hash      | [![npm][hash-version-badge]][npm-hash]           | [packages/hash](./packages/hash)           | [API](./docs/api/hash.md)      |\n| in-memory | [![npm][in-memory-version-badge]][npm-in-memory] | [packages/in-memory](./packages/in-memory) | [API](./docs/api/in-memory.md) |\n\n[browser-version-badge]: https://img.shields.io/npm/v/@hickory/browser.svg\n[npm-browser]: https://npmjs.com/package/@hickory/browser\n[hash-version-badge]: https://img.shields.io/npm/v/@hickory/hash.svg\n[npm-hash]: https://npmjs.com/package/@hickory/hash\n[in-memory-version-badge]: https://img.shields.io/npm/v/@hickory/in-memory.svg\n[npm-in-memory]: https://npmjs.com/package/@hickory/in-memory\n\n### Usage\n\nBelow is a quick introduction to the API of a history object.\n\n```js\nimport { Browser } from \"@hickory/browser\";\n\nlet history = Browser();\n\n// You must add a respond handler function. Whenever there\n// is navigation, that function will be called. It is responsible\n// for finishing the navigation. \"finish\" should not be called until\n// after any route matching/data loaded has finished running.\nhistory.respondWith(({ location, action, finish, cancel }) =\u003e {\n  console.log(\"Navigating to:\", location);\n  finish();\n});\n\n// All of the locations that are visited by the user of your\n// application will be stored in an array. An index value is used to keep\n// track of which location in the array is the current one.\n\n// There are two navigation methods that you can use to change locations.\n\n// navigate() is used for navigating to a new location.\n// It has three modes: \"anchor\", \"push\", and \"replace\".\n// \"push\" pushes the new location onto the session history after the current location\n// \"replace\" replaces the current location in the session history\n// \"anchor\" (default) acts like \"push\" for new locations and \"replace\" when the provided location\n//   is the same as the current location (the same behavior as clicking an \u003ca\u003e).\n// The first argument to navigate() is either a string or a partial location object.\n// The optional second argument is the navigation mode (\"anchor\" if not provided).\n\n// mode = \"anchor\"\nhistory.navigate(\"/next-location\");\n// mode = \"push\"\nhistory.navigate(\"/new-location\", \"push\");\n// mode = \"replace\"\nhistory.navigate(\"/same-location\", \"replace\");\n\n// go() is used to jump to existing locations in the session history.\n// negative values go backwards and positive values go forwards\n\n// current index = 4\nhistory.go(-2);\n// new index = 2\n\n// You might want to have you users confirm navigation before actually\n// switching pages. To do this, pass a confirmation function to the\n// confirm method.\n\nhistory.confirm(function(info, allow, prevent) {\n  let confirmed = window.confirm(\"Are you sure you want to navigate?\");\n  if (confirmed) {\n    allow();\n  } else {\n    prevent();\n  }\n});\n\n// Now, whenever there is navigation (the user clicks a link or the browser's\n// forward/back buttons), the confirmation function will be run and the\n// navigation will be cancelled if the prevent function is called.\n\n// In the above example, if the user clicks the cancel button of the\n// \"confirm\" popup, then the navigation will be cancelled. If the user clicks\n// the \"OK\" button, then the navigation will occur.\n\n// If/when you no longer want the user to have to confirm navigation, call\n// the confirm function with no argument and navigation will always happen.\n\nhistory.confirm();\n```\n\n### Browser Support\n\nBrowser testing is provided thanks to BrowserStack\n\n[\u003cimg src='./static/BrowserStackLogo.png' /\u003e](https://www.browserstack.com/start)\n\nThe following browsers are currently tested:\n\n- Chrome 63 on Windows 10\n- Firefox 57 on Windows 10\n- Internet Explorer 11 on Windows 10\n- Edge 16 on Windows 10\n- Safari 12 on macOS Mojave\n  \u003c!--* Safari on iOS 10.3\n- Chrome on Android 4.4--\u003e\n\n[version-badge]: https://img.shields.io/npm/v/hickory.svg\n[npm-hickory]: https://npmjs.com/package/hickory\n[build-badge]: https://img.shields.io/travis/pshrmn/hickory/master.svg\n[build]: https://travis-ci.org/pshrmn/hickory\n[browserstack-badge]: https://www.browserstack.com/automate/badge.svg?badge_key=bHVBTk00Sm9ucnJ5SDlaOE5MZW80R214K0F3ZlkwVlY5OHd1WjI0OWJaQT0tLVYra3dYSUVOOTlKTnJHZUdDSXZHbVE9PQ==--50fa09de197425afca33b06f04e61e7582f13259\n[browserstack-build]: https://www.browserstack.com/automate/public-build/bHVBTk00Sm9ucnJ5SDlaOE5MZW80R214K0F3ZlkwVlY5OHd1WjI0OWJaQT0tLVYra3dYSUVOOTlKTnJHZUdDSXZHbVE9PQ==--50fa09de197425afca33b06f04e61e7582f13259\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpshrmn%2Fhickory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpshrmn%2Fhickory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpshrmn%2Fhickory/lists"}