{"id":24057065,"url":"https://github.com/accounts-js/react","last_synced_at":"2025-04-23T01:16:57.510Z","repository":{"id":57094332,"uuid":"71761801","full_name":"accounts-js/react","owner":"accounts-js","description":"React (and React Native) view layer for js-accounts","archived":false,"fork":false,"pushed_at":"2020-10-01T20:38:20.000Z","size":335,"stargazers_count":7,"open_issues_count":13,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T01:16:50.041Z","etag":null,"topics":["accounts","material-ui","oauth","react","react-native","users"],"latest_commit_sha":null,"homepage":"","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/accounts-js.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":"2016-10-24T07:12:04.000Z","updated_at":"2020-05-07T17:38:11.000Z","dependencies_parsed_at":"2022-08-22T17:30:12.893Z","dependency_job_id":null,"html_url":"https://github.com/accounts-js/react","commit_stats":null,"previous_names":["js-accounts/react"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accounts-js%2Freact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accounts-js%2Freact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accounts-js%2Freact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/accounts-js%2Freact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/accounts-js","download_url":"https://codeload.github.com/accounts-js/react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250349060,"owners_count":21415914,"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":["accounts","material-ui","oauth","react","react-native","users"],"created_at":"2025-01-09T05:28:57.143Z","updated_at":"2025-04-23T01:16:57.491Z","avatar_url":"https://github.com/accounts-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @accounts/react\n\n## Note\n\nThis package is under active development.\n\n## Install\n\n```\nyarn add @accounts/react\nyarn add @accounts/client\nyarn add @accounts/rest-client\nyarn add @accounts/react-material-ui\n```\n\n## Usage\n\nThis is a simple example with react-router.\n\n```javascript\nimport AccountsClient from '@accounts/client';\nimport restClient from '@accounts/rest-client';\nimport { accountRoutes, withUser, Authenticated } from '@accounts/react';\n\n// If you want the material-ui view\nimport '@accounts/react-material-ui';\n\n// Setup client config and try to resume session to know if user is logged\n(async () =\u003e {\n  AccountsClient.config({\n    server: 'http://localhost:3010',\n    history: browserHistory,\n    title: 'my-app-title',\n    loginPath: '/login',\n    signUpPath: '/signup',\n    homePath: '/home',\n    reduxLogger: createLogger(),\n  }, restClient);\n\n  await AccountsClient.resumeSession();\n})();\n\n// The withUser hoc pass a user prop to the component\nconst Home = withUser(({ user }) =\u003e\n  \u003cdiv\u003e\n    Signed in user info\n    \u003cbr /\u003e\n    {Object.keys(user).map(key =\u003e \u003cdiv key={key}\u003e{key} : {user[key]} \u003c/div\u003e)}\n  \u003c/div\u003e,\n);\n\n// Use the Authenticated component in the router will check if a user is logged and redirect to /login if not\nrender((\n  \u003cMuiThemeProvider\u003e\n    \u003cRouter history={browserHistory}\u003e\n      \u003cRoute path=\"/\" component={Authenticated}\u003e\n        \u003cIndexRoute component={Home} /\u003e\n        \u003cRoute path=\"/home\" component={Home} /\u003e\n      \u003c/Route\u003e\n      {accountRoutes()}\n    \u003c/Router\u003e\n  \u003c/MuiThemeProvider\u003e\n), document.getElementById('root'));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccounts-js%2Freact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faccounts-js%2Freact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faccounts-js%2Freact/lists"}