@clerk/clerk-expo
Overview
Clerk is the easiest way to add authentication and user management to your Expo application. Add sign up, sign in, and profile management to your React Native application in minutes.
Getting Started
Prerequisites
- React v16+
- Node.js v14+
Installation
npm install @clerk/clerk-expo
Build
To build the package locally with the TypeScript compiler, run:
npm run build
To build the package in watch mode, run the following:
npm run dev
Usage
Clerk requires your application to be wrapped in the <ClerkProvider/>
context and passed your Frontend API as the frontendApi
prop.
With Expo, the entry point is typically App.js
:
import { ClerkProvider, useUser, withClerk } from '@clerk/clerk-expo';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
const frontendApi = 'clerk.[your-domain].[tld]';
export default function App() {
return (
<ClerkProvider frontendApi={frontendApi}>
<Main />
</ClerkProvider>
);
}
const Main = withClerk(({ clerk }) => {
const { user } = useUser({ withAssertions: true });
const handleSignIn = () => clerk.openSignIn();
const handleSignOut = () => clerk.signOut();
return (
<View style={styles.container}>
{user ? (
<>
<Text>You are signed in</Text>
<TouchableOpacity
style={styles.button}
onPress={handleSignOut}
>
<Text>Sign out</Text>
</TouchableOpacity>
</>
) : (
<TouchableOpacity
style={styles.button}
onPress={handleSignIn}
>
<Text>Sign in</Text>
</TouchableOpacity>
)}
</View>
);
});
For further details and examples, please refer to our Documentation.
Support
You can get in touch with us in any of the following ways:
- Join our official community Discord server
- Open a GitHub support issue
- Contact options listed on our Support page
Contributing
We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines.
Security
@clerk/clerk-expo
follows good practices of security, but 100% security cannot be assured.
@clerk/clerk-expo
is provided "as is" without any warranty. Use at your own risk.
For more information and to report security issues, please refer to our security documentation.
License
This project is licensed under the MIT license.
See LICENSE for more information.