{"id":48612202,"url":"https://github.com/breatheco-de/react-session","last_synced_at":"2026-04-09T00:35:02.843Z","repository":{"id":32937007,"uuid":"142048200","full_name":"breatheco-de/react-session","owner":"breatheco-de","description":"Create and maintain a sessions in react, compatible with React Router (login/logout) and sync with the localstorage","archived":false,"fork":false,"pushed_at":"2023-07-18T22:03:09.000Z","size":9024,"stargazers_count":24,"open_issues_count":46,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-09T02:26:08.976Z","etag":null,"topics":["front-end-sessions","react","react-component","react-library","react-login","react-logout","react-router-session","react-session","reactjs","session-management"],"latest_commit_sha":null,"homepage":"https://breatheco-de.github.io/react-session/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/breatheco-de.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-23T17:40:58.000Z","updated_at":"2024-04-09T15:03:20.000Z","dependencies_parsed_at":"2024-11-18T09:17:04.069Z","dependency_job_id":null,"html_url":"https://github.com/breatheco-de/react-session","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":"0.20833333333333337","last_synced_commit":"6d050e9d74357ddf4ee23b6f322faee586e08793"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/breatheco-de/react-session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breatheco-de%2Freact-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breatheco-de%2Freact-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breatheco-de%2Freact-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breatheco-de%2Freact-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/breatheco-de","download_url":"https://codeload.github.com/breatheco-de/react-session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breatheco-de%2Freact-session/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31580208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["front-end-sessions","react","react-component","react-library","react-login","react-logout","react-router-session","react-session","reactjs","session-management"],"created_at":"2026-04-09T00:35:02.702Z","updated_at":"2026-04-09T00:35:02.813Z","avatar_url":"https://github.com/breatheco-de.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://assets.breatheco.de/apis/img/images.php?blob\u0026random\u0026cat=icon\u0026tags=breathecode,128\"\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n    \u003ch2 align=\"center\"\u003e React Session Management \u003c/h2\u003e\n\u003c/p\u003e\n\n[![Maintenance](https://img.shields.io/badge/Maintained-yes-green.svg)](https://GitHub.com/breatheco-de/react-session.js/graphs/commit-activity)\n[![Tests](https://api.travis-ci.org/breatheco-de/react-session.svg?branch=master)](https://travis-ci.org/breatheco-de/react-session)\n[![npm](https://img.shields.io/npm/v/bc-react-session.svg)](https://www.npmjs.com/package/bc-react-session)\n[![npm](https://img.shields.io/npm/dm/bc-react-session.svg)](https://www.npmjs.com/package/bc-react-session)\n[![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/breatheco-de/react-session/blob/master/LICENSE)\n\n\nCreate and maintain persisten login sessions on the browser (even if the website is refreshed).\nCheckout the [live demo](https://breatheco-de.github.io/react-session/).\n\u003e Note: Extremely easy integration with [React Router](https://github.com/ReactTraining/react-router).\n\n## Installation\n\n```\n$ npm i --save bc-react-session\n```\n\n## Usage\n\n1) Open a session by doing `Session.login();`:\n\n```js\nimport {Session} from 'bc-react-session';\n\nSession.start({ \n\tpayload: {\n\t    // (optional) any info you want to save on the persisten session\n\t},\n\texpiration: 86400000; // (optional) defaults to 1 day\n});\n```\n\n2) Close the session by doing `Session.destroy();`:\n```js\nimport {Session} from 'bc-react-session';\n\nSession.destroy();\n```\n\n3) Retrieve the session and payload from anywhere\n```js\nimport {Session} from 'bc-react-session';\n\nconst session = Session.get();\nconst { payload } = Session.get();\n\nconsole.log(session.isValid); // will be true if is not expired or innactive\nconsole.log(payload); // anything you have set on the session payload is stored here\n\n```\n\n## That is it!!\n\n### Some other functionalities:\n\n1. Listen to session changes\n```js\n// listen to session changes\nconst unsubscribe = Session.onChange((session) =\u003e {\n  console.log(session);\n  \n  if(session.expired) console.log('The session has expired')\n  if(session.autenticated) console.log('No one has logged in')\n  \n});\n \n //unsubscribe to session changes if needed\nunsubscribe();\n```\n\n2. Wait for session expiration callback\n```js\n// you need to enforce before calling the login method.\nSession.onExpiration((session) =\u003e session.destroy()); //you can destroy the session if it expires\n```\n\n3. Change reset the session payload whenever you want\n```js\nimport {Session} from 'bc-react-session';\n\n// pass a new username that will override previous one (if any)\nSession.setPayload({\n    username: 'alesanchezr'\n});\n```\n\n4. Check session expiration\n```\nconst session = Session.get();\nconsole.log(session.expired); // boolean\n```\n\n5. Make a Private Route using react router\n\nThe library brings a component called `\u003cPrivateRoute /\u003e` to make your routes private without any extra code.\n\n```jsx\nimport {PrivateRoute} from 'bc-react-session';\n\n\u003cBrowserRouter\u003e\n    \u003cdiv\u003e\n        \u003cPrivateRoute exact path='/profile' component={PrivateLayout} /\u003e\n    \u003c/div\u003e\n\u003c/BrowserRouter\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreatheco-de%2Freact-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbreatheco-de%2Freact-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreatheco-de%2Freact-session/lists"}