{"id":18488535,"url":"https://github.com/watanabeyu/react-native-simple-twitter","last_synced_at":"2025-04-11T20:51:34.136Z","repository":{"id":54452633,"uuid":"115024657","full_name":"watanabeyu/react-native-simple-twitter","owner":"watanabeyu","description":"Twitter API client for react native without react-native link and react custom hook","archived":false,"fork":false,"pushed_at":"2021-02-17T01:53:23.000Z","size":2061,"stargazers_count":87,"open_issues_count":6,"forks_count":45,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T16:51:39.952Z","etag":null,"topics":["customhooks","expo","javascript","react-native","twitter","twitter-api","typescript"],"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/watanabeyu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"watanabeyu"}},"created_at":"2017-12-21T16:17:17.000Z","updated_at":"2025-02-13T12:18:49.000Z","dependencies_parsed_at":"2022-08-13T16:10:20.967Z","dependency_job_id":null,"html_url":"https://github.com/watanabeyu/react-native-simple-twitter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watanabeyu%2Freact-native-simple-twitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watanabeyu%2Freact-native-simple-twitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watanabeyu%2Freact-native-simple-twitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watanabeyu%2Freact-native-simple-twitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watanabeyu","download_url":"https://codeload.github.com/watanabeyu/react-native-simple-twitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480512,"owners_count":21110936,"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":["customhooks","expo","javascript","react-native","twitter","twitter-api","typescript"],"created_at":"2024-11-06T12:51:52.510Z","updated_at":"2025-04-11T20:51:34.089Z","avatar_url":"https://github.com/watanabeyu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/watanabeyu"],"categories":["TypeScript"],"sub_categories":[],"readme":"# **If you have request, Please send a PR or issue.**\n* please see [CHANGELOG.md](CHANGELOG.md)\n* `TWLoginButton` / `twitter.get()` / `twitter.post()` will be removed on next version (v3.1.0).\n\n# React-Native-Simple-Twitter v3.0\nTwitter API client for React Native without `react-native link`.  \nThis package **don't use NativeModule**, only pure javascript.  \nSo don't need to use `react-native link` and [Expo](https://expo.io) can also easily use twitter API without auth0 and server.\n  \nYou can use custom hooks from v3.0\n\n```\n...\nimport { useTwitter } from \"react-native-simple-twitter\";\n\nfunction Login() {\n  // if login, please set onSuccess\n  const { twitter,TWModal } = useTwitter({\n    onSuccess:(user,accessToken) =\u003e {\n      console.log(user);\n      console.log(accessToken);\n    }\n  });\n\n  const onLoginPress = async () =\u003e {\n    try {\n      await twitter.login();\n    } catch(e) {\n      console.log(e.errors);\n    }\n  }\n\n  useEffect(() =\u003e {\n    twitter.setConsumerKey(\"key\",\"secret\");\n  },[]);\n\n  ...\n\n  return (\n    \u003cView\u003e\n      \u003cText onPress={onLoginPress}\u003elogin\u003c/Text\u003e\n      \u003cTWModal /\u003e\n    \u003c/View\u003e\n  )\n}\n```\n  \nCheckout v3.x [example](example).  \n  \nPrevious version -\u003e [v2.4.1](https://github.com/watanabeyu/react-native-simple-twitter/tree/2759e423db803d31f50bdb24adcabbf43afd925d) \n\n## Installation\nThis package use WebView, but WebView from react-native is deprecated, so you download with `react-native-webview`.\n```bash\n$ npm install react-native-simple-twitter react-native-webview --save\n```\n\nif you want to use more twitter types, use [abraham/twitter-d](https://github.com/abraham/twitter-d)\n```bash\n$ npm install --save-dev twitter-d\n```\n\n## Demo\n![demo gif](extras/demo.gif)\n\n## useTwitter API\n```\nimport { useTwitter } from 'react-native-simple-twitter';\n\nconst { twitter, TWModal } = useTwitter({\n  onSuccess:(user,accessToken) =\u003e void,\n  onError?:(err) =\u003e void,\n})\n```\n\n### useTwitter()\n| Name | Description |\n| --- | --- |\n| `onSuccess:(user,accessToken) =\u003e void` | return loggedin user object and access token |\n| `onError?:(err) =\u003e void` | if login failed, call this method |\n\n### twitter\n| Name | Description |\n| --- | --- |\n| `twitter.login()` | Get login url and open TWModal |\n| `twitter.setConsumerKey(consumer_key,consumer_key_secret)` | set application key and secret |\n| `twitter.getAccessToken()` | get access_token and access_token_secret, when user logged in app |\n| `twitter.setAccessToken(access_token,access_token_secret)` | set user access_token and access_token_secret, when you already have access_token and access_token_secret |\n| `twitter.api(\"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\",endpoint,parameters?)` | call twitter api |\n| `twitter.get(endpoint,parameters)` | alias of `twitter.api`. **this method will be deprecated** |\n| `twitter.post(endpoint,parameters)` | alias of `twitter.api`. **this method will be deprecated** |\n\n## Other API\n\n* decodeHTMLEntities\n```js\nimport { decodeHTMLEntities } from 'react-native-simple-twitter'\n\nconsole.log(decodeHTMLEntities(\"\u0026amp; \u0026apos; \u0026#x27; \u0026#x2F; \u0026#39; \u0026#47; \u0026lt; \u0026gt; \u0026nbsp; \u0026quot;\"))\n```\nTweet is include htmlencoded characters.  \nSo this function decode special characters.\n\n* getRelativeTime\n```js\nimport { getRelativeTime } from 'react-native-simple-twitter'\n\nconsole.log(getRelativeTime(new Date(new Date().getTime() - 32390)))\nconsole.log(getRelativeTime(\"Thu Apr 06 15:28:43 +0000 2017\"))\n```\nTweet created_at convert to relative time.\nex) 1s 15m 23h","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatanabeyu%2Freact-native-simple-twitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatanabeyu%2Freact-native-simple-twitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatanabeyu%2Freact-native-simple-twitter/lists"}