-
Notifications
You must be signed in to change notification settings - Fork 453
feat(clerk-expo)!: React Native >= 0.73 and Expo Web support #3456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
c38211d
feat(expo): Support for Expo Web
octoper 08754f5
chore(repo): Add Changeset
octoper 96b3cb2
chore(expo): Update package.json
octoper bc0c3c5
fix(expo): Throw error when using component in native platforms
octoper b95559c
chore(expo): Use error thrower and move useOAuth hook
octoper bede556
chore(expo): Remove custom messages array from errorThrower
octoper 625dbf2
chore(expo): Update the structure of the package
octoper c3fd056
fix(expo): Wrong type import in ClerkProvider
octoper c40d1a9
fix(expo): Fix wrong type import
octoper acad398
chore(expo): Make useOAuth base implementation to be the native one
octoper a0193c2
chore(expo): Remove console.logs from useOAuth
octoper fe55ada
chore(clerk-expo): User react 18.2.0
octoper 847278f
chore: Update dependencies
octoper 7a05874
feat(expo): Introducing web subpath for web only APIs & Components
octoper 16b456a
chore(expo): Fix type issues
octoper b8c51f8
chore(expo): Fix web subpath exports
octoper 47348ca
feat(expo): Only bundle Clerk in native platforms
octoper a5dd66f
fix(expo): Make useOAuth available to web
octoper e6425dd
feat(e2e): Introduce integration tests for Expo Web
octoper 2be2f8d
chore(e2e): Setting up integration tests for Expo Web
octoper 6643c23
chore(e2e): Fix issues for resolving dependencies in integration tests
octoper 525ca3b
chore(e2e): Add expoWeb integration suite to CI action
octoper 38ff442
fix(repo): Fix @clerk/types invalid version issue
octoper 54c4d9b
fix(e2e): Remove headed mode from expo web integration script
octoper 661f3d6
chore(repo): Add test:integration:expoWeb in Turbo
octoper 636a6a7
chore(e2e): Use dev instead of build
octoper 98fa6b1
chore(e2e): Update test:integration:expoWeb in Turbo
octoper b6c5dc3
chore(e2e): Add log for clerkExpoPath
octoper 892683d
chore(e2e): Add log for clerkExpoPath
octoper 7eb8ff5
chore(e2e): debug ci
octoper ca8fb07
chore(e2e): debug ci
octoper 4f239c4
chore(e2e): debug ci
octoper b4c59b0
chore(e2e): debug ci
octoper 307acb2
chore(e2e): debug ci
octoper 2951bf5
chore(e2e): remove debug related stuff from metro.config.js
octoper 5c54f27
chore(e2e): added more tests
octoper 96b3311
chore(expo): User errorThrower in useOAuth
octoper 8f54cfd
chore(e2e): debug ci
octoper 837dd23
fix(expo): Handle authentication completion from popup on Web
octoper 4e4c2f9
fix(expo): Remove react-native specific exports
octoper 35a73ac
chore(expo): Remove not needed version range for react-native
octoper f70c051
feat(expo): Exported more UI components for Web
octoper 3a8a097
fix(expo): Correctly export web subpath
octoper dcf2b88
fix(e2e): Fix Expo Web tests
octoper 1243186
chore(clerk-expo): Move caches to cache so we don't introduce breakin…
octoper 346a021
chore(clerk-expo): Lower react-native peer dep version to 0.72
octoper 5e11b13
chore(e2e): Remove uneeded assets from expo-web template
octoper bd74b69
chore(clerk-expo): Remove skipNodeModulesBundle from tsup.config.ts
octoper 6cf3ec8
chore(clerk-expo): Added process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KE…
octoper 297edbd
chore(clerk-expo): Require react-native >= 0.73 and bump Expo peer de…
octoper cda7584
chore(repo): Update changeset
octoper 7119e0b
improve changeset
LekoArts c216d72
improve README
LekoArts edd05ab
chore(e2e): Chnage expoWeb to expo-web
octoper a853d35
chore(clerk-expo): Use specific version of react-native-url-polyfill
octoper df1e607
chore(e2e): Chnage expoWeb to expo-web
octoper d1ca5a4
Update packages/expo/src/web/uiComponents.tsx
octoper c45c61c
chore(clerk-expo): Use default exports as we only support cjs
octoper 1683660
chore(clerk-expo): Update error message for components used in native…
octoper 999ed09
fix(clerk-expo): Fix getClerkInstance for web as it was not a function
octoper 156c736
chore(clerk-expo): Update JSDOC of getClerkInstance
octoper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| '@clerk/clerk-expo': major | ||
| --- | ||
|
|
||
| Support for [Expo Web](https://docs.expo.dev/workflow/web/) has been added! You can now build fullstack websites with Expo, React, and Clerk. Utilize [Clerk's components](https://clerk.com/docs/components/overview) to build out your app. | ||
|
|
||
| You can access the components from the `/web` subpath import like so: | ||
|
|
||
| ```tsx | ||
| import { SignUp } from "@clerk/clerk-expo/web"; | ||
|
|
||
| export default function Page() { | ||
| return <SignUp />; | ||
| } | ||
| ``` | ||
|
|
||
| **Breaking change:** You need to use Expo 50 or later. The minimum required React Native version was bumped to `0.73`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { applicationConfig } from '../models/applicationConfig'; | ||
| import { templates } from '../templates'; | ||
|
|
||
| const clerkExpoLocal = `file:${process.cwd()}/packages/expo`; | ||
|
|
||
| const expoWeb = applicationConfig() | ||
| .setName('expo-web') | ||
| .useTemplate(templates['expo-web']) | ||
| .setEnvFormatter('public', key => `EXPO_PUBLIC_${key}`) | ||
| .addScript('setup', 'npm i') | ||
| .addScript('dev', 'npm run dev') | ||
| .addScript('build', 'npm run build') | ||
| .addScript('serve', 'npm run start') | ||
| .addDependency('@clerk/clerk-expo', clerkExpoLocal); | ||
|
|
||
| export const expo = { | ||
| expoWeb, | ||
| } as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| node_modules/ | ||
| .expo/ | ||
| dist/ | ||
| npm-debug.* | ||
| *.jks | ||
| *.p8 | ||
| *.p12 | ||
| *.key | ||
| *.mobileprovision | ||
| *.orig.* | ||
| web-build/ | ||
|
|
||
| # macOS | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Welcome to your Expo app 👋 | ||
|
|
||
| This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). | ||
|
|
||
| ## Get started | ||
|
|
||
| 1. Install dependencies | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 2. Start the app | ||
|
|
||
| ```bash | ||
| npx expo start | ||
| ``` | ||
|
|
||
| In the output, you'll find options to open the app in a | ||
|
|
||
| - [development build](https://docs.expo.dev/develop/development-builds/introduction/) | ||
| - [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) | ||
| - [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) | ||
| - [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo | ||
|
|
||
| You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). | ||
|
|
||
| ## Get a fresh project | ||
|
|
||
| When you're ready, run: | ||
|
|
||
| ```bash | ||
| npm run reset-project | ||
| ``` | ||
|
|
||
| This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. | ||
|
|
||
| ## Learn more | ||
|
|
||
| To learn more about developing your project with Expo, look at the following resources: | ||
|
|
||
| - [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). | ||
| - [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. | ||
|
|
||
| ## Join the community | ||
|
|
||
| Join our community of developers creating universal apps. | ||
|
|
||
| - [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. | ||
| - [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "expo": { | ||
| "name": "expo-web", | ||
| "slug": "expo-web", | ||
| "version": "1.0.0", | ||
| "orientation": "portrait", | ||
| "icon": "./assets/images/icon.png", | ||
| "scheme": "myapp", | ||
| "userInterfaceStyle": "automatic", | ||
| "splash": { | ||
| "image": "./assets/images/splash.png", | ||
| "resizeMode": "contain", | ||
| "backgroundColor": "#ffffff" | ||
| }, | ||
| "ios": { | ||
| "supportsTablet": true | ||
| }, | ||
| "android": { | ||
| "adaptiveIcon": { | ||
| "foregroundImage": "./assets/images/icon.png", | ||
| "backgroundColor": "#ffffff" | ||
| } | ||
| }, | ||
| "web": { | ||
| "bundler": "metro", | ||
| "output": "static", | ||
| "favicon": "./assets/images/icon.png" | ||
| }, | ||
| "plugins": ["expo-router"], | ||
| "experiments": { | ||
| "typedRoutes": true | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { ScrollViewStyleReset } from 'expo-router/html'; | ||
| import type { PropsWithChildren } from 'react'; | ||
|
|
||
| /** | ||
| * This file is web-only and used to configure the root HTML for every web page during static rendering. | ||
| * The contents of this function only run in Node.js environments and do not have access to the DOM or browser APIs. | ||
| */ | ||
| export default function Root({ children }: PropsWithChildren) { | ||
| return ( | ||
| <html lang='en'> | ||
| <head> | ||
| <meta charSet='utf-8' /> | ||
| <meta | ||
| httpEquiv='X-UA-Compatible' | ||
| content='IE=edge' | ||
| /> | ||
| <meta | ||
| name='viewport' | ||
| content='width=device-width, initial-scale=1, shrink-to-fit=no' | ||
| /> | ||
|
|
||
| {/* | ||
| Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. | ||
| However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. | ||
| */} | ||
| <ScrollViewStyleReset /> | ||
|
|
||
| {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} | ||
| <style dangerouslySetInnerHTML={{ __html: responsiveBackground }} /> | ||
| {/* Add any additional <head> elements that you want globally available on web... */} | ||
| </head> | ||
| <body>{children}</body> | ||
| </html> | ||
| ); | ||
| } | ||
|
|
||
| const responsiveBackground = ` | ||
| body { | ||
| background-color: #fff; | ||
| } | ||
| @media (prefers-color-scheme: dark) { | ||
| body { | ||
| background-color: #000; | ||
| } | ||
| }`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { Link, Stack } from 'expo-router'; | ||
| import { StyleSheet, Text } from 'react-native'; | ||
|
|
||
| export default function NotFoundScreen() { | ||
| return ( | ||
| <> | ||
| <Stack.Screen options={{ title: 'Oops!', headerShown: true }} /> | ||
| <Text>This screen doesn't exist.</Text> | ||
| <Link href='/'> | ||
| <Text>Go to home screen!</Text> | ||
| </Link> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Stack, useRouter } from 'expo-router'; | ||
| import { ClerkLoaded, ClerkProvider } from '@clerk/clerk-expo'; | ||
|
|
||
| export default function RootLayout() { | ||
| const router = useRouter(); | ||
|
|
||
| return ( | ||
| <ClerkProvider | ||
| routerPush={(to: string) => router.push(to)} | ||
| routerReplace={to => router.replace(to)} | ||
| > | ||
| <ClerkLoaded> | ||
| <Stack> | ||
| <Stack.Screen name='index' /> | ||
| </Stack> | ||
| </ClerkLoaded> | ||
| </ClerkProvider> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { useSignIn } from '@clerk/clerk-expo'; | ||
| import { Link, useRouter } from 'expo-router'; | ||
| import { Text, TextInput, Button, View } from 'react-native'; | ||
| import React from 'react'; | ||
|
|
||
| export default function Page() { | ||
| const { signIn, setActive, isLoaded } = useSignIn(); | ||
| const router = useRouter(); | ||
|
|
||
| const [emailAddress, setEmailAddress] = React.useState(''); | ||
| const [password, setPassword] = React.useState(''); | ||
|
|
||
| const onSignInPress = React.useCallback(async () => { | ||
| if (!isLoaded) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const signInAttempt = await signIn.create({ | ||
| identifier: emailAddress, | ||
| password, | ||
| }); | ||
|
|
||
| if (signInAttempt.status === 'complete') { | ||
| await setActive({ session: signInAttempt.createdSessionId }); | ||
| router.replace('/'); | ||
| } else { | ||
| // See https://clerk.com/docs/custom-flows/error-handling | ||
| // for more info on error handling | ||
| console.error(JSON.stringify(signInAttempt, null, 2)); | ||
| } | ||
| } catch (err: any) { | ||
| console.error(JSON.stringify(err, null, 2)); | ||
| } | ||
| }, [isLoaded, emailAddress, password]); | ||
|
|
||
| return ( | ||
| <View> | ||
| <TextInput | ||
| autoCapitalize='none' | ||
| value={emailAddress} | ||
| placeholder='Email...' | ||
| id='emailAddress' | ||
| testID='emailAddress-input' | ||
| onChangeText={emailAddress => setEmailAddress(emailAddress)} | ||
| /> | ||
| <TextInput | ||
| value={password} | ||
| placeholder='Password...' | ||
| secureTextEntry={true} | ||
| id='password' | ||
| testID='password-input' | ||
| onChangeText={password => setPassword(password)} | ||
| /> | ||
| <Button | ||
| title='Sign In' | ||
| onPress={onSignInPress} | ||
| /> | ||
| <View> | ||
| <Text>Don't have an account?</Text> | ||
| <Link href='/sign-up'> | ||
| <Text>Sign up</Text> | ||
| </Link> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.