@gcou/react-native-linkedin

中文文档
2.5.2发布于 2026/09/08MITCommonJS近 30 天下载 2128

React-Native LinkedIn, a simple LinkedIn login library for React-Native with WebView and Modal - compatibility with RN 0.81.1+

原始使用文档
文档目录13 节
  1. 🔗 React-Native LinkedIn
  2. Benefits
  3. Installation
  4. Peer Dependencies
  5. Security
  6. Example
  7. Props
  8. Contribution
  9. FAQ
  10. Is it supported and tested both on android and iOS?
  11. How to logout react-native-linkedin?
  12. Alternatives
  13. Licence

react-native-linkedin

🔗 React-Native LinkedIn

Simple LinkedIn login library for React-Native with WebView into a Modal


Benefits

  • Light: No need to link a native library like others alternatives
  • Simple: Get the token and the expires, you handle your own login with the access_token
  • Sure: open-source
  • Almost readable & understandable code: JavaScript & React

Installation

$ yarn add @gcou/react-native-linkedin

Peer Dependencies

PackageMinimum version
react>=19.1.0
react-native>=0.81.1
react-native-get-random-values>=2.0.0
react-native-webview*

Security

Please note that you should give your linkedin client id but not your secret key to this component. You should be aware that key can be found if you store it directly to your code. I strongly recommend to not declare client secret key on your code but found a way to keep it secret

  <LinkedInModal
    shouldGetAccessToken={false}
    clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
    redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
    onSuccess={({ authentication_code }) => console.log(`Post this ${authentication_code} to your server.`)}
  />

Example

// See ./example/App.tsx file for details
import React, { ReactElement, useRef } from 'react';
import { StyleSheet, View, Button } from 'react-native';

import LinkedInModal, { LinkedInModalRef } from '@gcou/react-native-linkedin';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    alignItems: 'center',
  },
})

export default function AppContainer() : ReactElement {
  const linkedRef = useRef<LinkedInModalRef>(null);
  
  return (
    <View style={styles.container}>
      <LinkedInModal
        ref={linkedRef}
        clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
        clientSecret="[ Your client secret from https://www.linkedin.com/developer/apps ]"
        redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
        onSuccess={token => console.log(token)}
      />
      <Button title="Log Out" onPress={() => linkedRef.current?.logoutAsync()} />
    </View>
  )
}

Props

NameTypeRequiredDefaultDescription
clientIDstringrequiredYour client id
clientSecretstringuse shouldGetAccessToken={false} and read authorization_code onSuccess returnShould not be stored in app WARNING! Your client secret
redirectUristringrequiredYour redirectUri
onSuccessfunctionrequiredFunction will be call back on success
authStatestringoptionalrequire('uuid').v4()The state of auth, to be more secure
onErrorfunctionoptionalconsole.error(err)Function will be call back on error
onClosefunctionoptionalFunction will be call back on close modal
onOpenfunctionoptionalFunction will be call back on open modal
onSignInfunctionoptionalFunction will be call back when the user sign in
permissionsstring[]optional'r_liteprofile', 'r_emailaddress'The LinkedIn access token permissions
renderButtonReactElementoptionalRender for customize LinkedIn button
renderCloseReactElementoptionalRender for customize close button
linkTextstringoptional'Login with LinkedIn'Link label
containerStyleStylePropoptionalCustomize container style
wrapperStyleStylePropoptionalCustomize wrapper style
closeStyleStylePropoptionalCustomize close style
animationTypeModal.propTypes.animationTypeoptionalfadeCustomize animationType style: 'none', 'slide' or 'fade'
shouldGetAccessTokenbooloptionaltrueSet to false to receive the 'authorization code' rather then the 'access token'
areaTouchTextobjectoptional{top: 20, bottom: 20, left: 50, right: 50}Set values for to increase the text touch area
isDisabledbooloptionalfalseDisable the LinkedIn login button

Contribution

PRs are welcome!

FAQ

Is it supported and tested both on android and iOS?

YES

How to logout react-native-linkedin?

<View style={styles.container}>
    <LinkedInModal
      ref={linkedRef}
      clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
      clientSecret="[ Your client secret from https://www.linkedin.com/developer/apps ]"
      redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
      onSuccess={token => console.log(token)}
    />
    <Button title="Log Out" onPress={() => linkedRef.current?.logoutAsync()} />
</View>

Alternatives

Licence

MIT

made with ♥

版本与发布记录

@gcou/react-native-linkedin 共发布 19 个版本,首次发布于 2022/08/05;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.5.2latest2026/09/082 个月前
2.5.12026/06/125 个月前
2.5.02026/01/289 个月前
2.3.42025/09/261.1 年前
2.3.32025/08/201.2 年前
2.3.22025/08/201.2 年前

关于 @gcou/react-native-linkedin 的常见问题

@gcou/react-native-linkedin 是什么?

React-Native LinkedIn, a simple LinkedIn login library for React-Native with WebView and Modal - compatibility with RN 0.81.1+

如何安装 @gcou/react-native-linkedin?

在项目目录运行 npm install @gcou/react-native-linkedin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.1.0)、react-native(>=0.81.1)、react-native-get-random-values(>=2.0.0)、react-native-webview(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gcou/react-native-linkedin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gcou__react-native-linkedin 是否存在。

@gcou/react-native-linkedin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gcou/react-native-linkedin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 22.13.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gcou/react-native-linkedin 可以商用吗?

@gcou/react-native-linkedin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gcou/react-native-linkedin 的下载量有多少?

根据 npm 官方下载统计,@gcou/react-native-linkedin 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,128 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gcou/react-native-linkedin 还在维护吗?

最新版本 2.5.2 发布于 2026/09/08(2 个月前);至今共发布 19 个版本,其中过去 12 个月发布了 3 个;首次发布于 2022/08/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。