{"id":15647379,"url":"https://github.com/hypnosphi/qhistory","last_synced_at":"2025-04-30T13:07:26.846Z","repository":{"id":65420032,"uuid":"81631591","full_name":"Hypnosphi/qhistory","owner":"Hypnosphi","description":"Wrap history with query support","archived":false,"fork":false,"pushed_at":"2020-07-29T18:39:59.000Z","size":13,"stargazers_count":44,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-09T22:06:25.959Z","etag":null,"topics":["history","react-router"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Hypnosphi.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-02-11T04:53:42.000Z","updated_at":"2022-02-03T11:42:35.000Z","dependencies_parsed_at":"2023-01-22T18:35:11.304Z","dependency_job_id":null,"html_url":"https://github.com/Hypnosphi/qhistory","commit_stats":null,"previous_names":["pshrmn/qhistory"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypnosphi%2Fqhistory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypnosphi%2Fqhistory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypnosphi%2Fqhistory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypnosphi%2Fqhistory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hypnosphi","download_url":"https://codeload.github.com/Hypnosphi/qhistory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234077210,"owners_count":18775845,"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","react-router"],"created_at":"2024-10-03T12:19:04.600Z","updated_at":"2025-01-15T17:34:08.571Z","avatar_url":"https://github.com/Hypnosphi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qhistory\n\nAdd query object support to [`history`](https://github.com/ReactTraining/history) library location objects.\n\nYou will need to supply `stringify` and `parse` methods.\n\n#### `stringify`\n\nA function that takes a query object and returns a search string.\n\n```js\nstringify({ occupation: 'computer' }) // 'occupation=computer'\n```\n\n#### `parse`\n\nA function that takes a search string and returns a query object.\n\n```js\nparse('stopDownloading=true') // { stopDownloading: 'true' }\n```\n\nThere are lots of different query string packages that you can choose from. Some popular ones include:\n\n* [`qs`](https://www.npmjs.com/package/qs)\n* [`query-string`](https://www.npmjs.com/package/query-string)\n* [`querystring`](https://www.npmjs.com/package/querystring)\n\nThere may be subtle differences in the way that each parses and stringifies, so you will need to determine which supports the features that you want.\n\n### Installation\n\n```\nnpm install --save qhistory\n```\n\n### Usage\n\n```js\nimport { createBrowserHistory } from 'history'\nimport qhistory from 'qhistory'\n\nimport { stringify, parse } from 'qs'\n\nconst history = qhistory(\n  createBrowserHistory({ /* history configuration options */ }),\n  stringify,\n  parse\n)\n```\n\n#### Usage with React Router\n\nThis can be used with React Router v4 to add query string support to location objects. If a location object has both a search string and a query object, the search string's value will be overwritten by the stringified query object.\n\n```js\nimport { Router } from 'react-router-dom'\nimport { createBrowserHistory } from 'history'\nimport qhistory from 'qhistory'\n\nimport { stringify, parse } from 'qs'\n\nconst history = qhistory(\n  createBrowserHistory({ /* history configuration options */ }),\n  stringify,\n  parse\n)\n\nrender((\n  \u003cRouter history={history}\u003e\n    \u003cApp /\u003e\n  \u003c/Router\u003e\n), document.getElementById('root'))\n```\n\n#### If you're using React Router 4's BrowserRouter you can incorporate qhistory like this:\n\n```js\nclass QueryRouter extends React.Component {\n  static propTypes = {\n    basename: PropTypes.string,\n    forceRefresh: PropTypes.bool,\n    getUserConfirmation: PropTypes.func,\n    keyLength: PropTypes.number,\n    children: PropTypes.node,\n    stringify: PropTypes.func,\n    parse: PropTypes.func,\n  }\n\n  history = qhistory(\n    createBrowserHistory(this.props),\n    this.props.stringify,\n    this.props.parse\n  )\n\n  render() {\n    return \u003cRouter history={this.history} children={this.props.children} /\u003e\n  }\n}\n\n// usage\nrender((\n  \u003cQueryRouter stringify={stringify} parse={parse}\u003e\n    \u003cApp /\u003e\n  \u003c/QueryRouter\u003e\n), document.getElementbyId('root'))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypnosphi%2Fqhistory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypnosphi%2Fqhistory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypnosphi%2Fqhistory/lists"}