Skip to content

Commit 7459983

Browse files
committed
converting clerk to supabase auth
1 parent 297d661 commit 7459983

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3946
-6426
lines changed

.env.example

+2-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,8 @@
44
# This file will be committed to version control, so make sure not to have any secrets in it.
55
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.
66

7-
# AWS
8-
AWS_PROFILE="default"
9-
AWS_REGION="us-east-1"
10-
11-
# Clerk
12-
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
13-
CLERK_SECRET_KEY=
14-
CLERK_JWT_KEY="-----BEGIN PUBLIC KEY-----
15-
...
16-
-----END PUBLIC KEY-----
17-
"
18-
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/signin
19-
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/signup
7+
# The database URL is used to connect to your Supabase database.
8+
POSTGRES_URL="postgres://postgres.[USERNAME]:[PASSWORD]@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?workaround=supabase-pooler.vercel"
209

2110
# FastAPI
2211
NEXT_PUBLIC_FASTAPI_URL="http://127.0.0.1:8000"

.vscode/hyper.code-workspace

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"search.useIgnoreFiles": true,
2929
// use root .gitignore to ignore files from search
3030
"search.useParentIgnoreFiles": true,
31+
"typescript.tsdk": "Root/node_modules/typescript/lib",
3132
},
3233
"launch": {
3334
"version": "0.2.0",

apps/expo/.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_"
1+
EXPO_PUBLIC_SUPABASE_URL="https://YOUR_PROJECT_REF.supabase.co"
2+
EXPO_PUBLIC_SUPABASE_ANON_KEY="YOUR_ANON_KEY"
23
EXPO_PUBLIC_FASTAPI_URL="http://localhost:8000"

apps/expo/eas.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
},
55
"build": {
66
"base": {
7-
"node": "18.16.1",
7+
"node": "20.16.0",
8+
"pnpm": "9.6.0",
89
"ios": {
910
"resourceClass": "m-medium"
1011
}
@@ -14,7 +15,9 @@
1415
"developmentClient": true,
1516
"distribution": "internal",
1617
"env": {
17-
"EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY": "pk_test_Y2hlZXJmdWwtc3RhcmZpc2gtMjYuY2xlcmsuYWNjb3VudHMuZGV2JA"
18+
"EXPO_PUBLIC_SUPABASE_URL": "https://dnnqvouwzxzejzkvmqfk.supabase.co",
19+
"EXPO_PUBLIC_SUPABASE_ANON_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRubnF2b3V3enh6ZWp6a3ZtcWZrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjI0NTY0NjQsImV4cCI6MjAzODAzMjQ2NH0.I12jE7YC7h7B1qu1zYsBgzu3LQFj8CXNolevtxYpxU0",
20+
"EXPO_PUBLIC_FASTAPI_URL": "http://localhost:8000"
1821
}
1922
},
2023
"preview": {

apps/expo/package.json

+54-53
Original file line numberDiff line numberDiff line change
@@ -21,104 +21,105 @@
2121
},
2222
"dependencies": {
2323
"@bacons/text-decoder": "^0.0.0",
24-
"@clerk/clerk-expo": "^1.2.3",
25-
"@expo/metro-config": "^0.18.3",
26-
"@expo/vector-icons": "^14.0.0",
27-
"@gorhom/bottom-sheet": "^4.6.3",
28-
"@hookform/resolvers": "^3.3.4",
29-
"@radix-ui/react-label": "^2.0.2",
30-
"@radix-ui/react-progress": "^1.0.3",
31-
"@radix-ui/react-tooltip": "^1.0.7",
32-
"@react-native-async-storage/async-storage": "1.23.1",
33-
"@react-navigation/drawer": "^6.6.15",
34-
"@react-navigation/native": "^6.1.17",
24+
"@expo/metro-config": "^0.18.10",
25+
"@expo/vector-icons": "^14.0.2",
26+
"@gorhom/bottom-sheet": "^4.6.4",
27+
"@hookform/resolvers": "^3.9.0",
3528
"@hyper/validators": "workspace:*",
36-
"@shopify/flash-list": "1.6.4",
29+
"@radix-ui/react-label": "^2.1.0",
30+
"@radix-ui/react-progress": "^1.1.0",
31+
"@radix-ui/react-tooltip": "^1.1.2",
32+
"@react-native-async-storage/async-storage": "1.24.0",
33+
"@react-navigation/drawer": "^6.7.2",
34+
"@react-navigation/native": "^6.1.18",
35+
"@shopify/flash-list": "1.7.0",
36+
"@supabase/auth-helpers-react": "catalog:supabase",
37+
"@supabase/supabase-js": "catalog:supabase",
3738
"@tanstack/react-query": "catalog:",
3839
"@trpc/client": "catalog:",
3940
"@trpc/react-query": "catalog:",
4041
"@trpc/server": "catalog:",
4142
"class-variance-authority": "^0.7.0",
4243
"clsx": "^2.1.1",
43-
"expo": "^51.0.16",
44-
"expo-apple-authentication": "~6.4.1",
45-
"expo-av": "~14.0.5",
46-
"expo-build-properties": "~0.12.3",
44+
"expo": "^51.0.24",
45+
"expo-apple-authentication": "~6.4.2",
46+
"expo-av": "~14.0.6",
47+
"expo-build-properties": "~0.12.4",
4748
"expo-clipboard": "~6.0.3",
4849
"expo-constants": "~16.0.2",
4950
"expo-crypto": "~13.0.2",
50-
"expo-dev-client": "~4.0.18",
51+
"expo-dev-client": "~4.0.21",
5152
"expo-file-system": "~17.0.1",
52-
"expo-font": "~12.0.7",
53+
"expo-font": "~12.0.9",
5354
"expo-haptics": "~13.0.1",
54-
"expo-image": "~1.12.12",
55+
"expo-image": "~1.12.13",
5556
"expo-keep-awake": "~13.0.2",
5657
"expo-linear-gradient": "~13.0.2",
5758
"expo-linking": "~6.3.1",
58-
"expo-navigation-bar": "~3.0.6",
59-
"expo-notifications": "~0.28.9",
60-
"expo-router": "~3.5.16",
61-
"expo-secure-store": "~13.0.1",
59+
"expo-navigation-bar": "~3.0.7",
60+
"expo-notifications": "~0.28.14",
61+
"expo-router": "~3.5.20",
62+
"expo-secure-store": "~13.0.2",
6263
"expo-sharing": "~12.0.1",
6364
"expo-splash-screen": "~0.27.5",
6465
"expo-status-bar": "~1.12.1",
65-
"expo-system-ui": "~3.0.6",
66-
"expo-updates": "~0.25.17",
66+
"expo-system-ui": "~3.0.7",
67+
"expo-updates": "~0.25.21",
6768
"expo-web-browser": "~13.0.3",
68-
"lucide-react-native": "^0.379.0",
69+
"lucide-react-native": "^0.418.0",
6970
"nativewind": "^4.0.36",
70-
"openai": "^4.47.1",
71+
"openai": "^4.53.2",
7172
"react": "catalog:react18",
7273
"react-dom": "catalog:react18",
73-
"react-hook-form": "^7.51.4",
74-
"react-native": "~0.74.2",
74+
"react-hook-form": "^7.52.1",
75+
"react-native": "~0.74.4",
7576
"react-native-avoid-softinput": "^5.0.0",
76-
"react-native-gesture-handler": "~2.16.2",
77+
"react-native-gesture-handler": "~2.18.0",
7778
"react-native-ios-context-menu": "^2.5.1",
7879
"react-native-ios-utilities": "^4.4.5",
79-
"react-native-keyboard-controller": "^1.12.1",
80+
"react-native-keyboard-controller": "^1.12.7",
8081
"react-native-mmkv": "^2.12.2",
8182
"react-native-openai": "^0.6.1",
82-
"react-native-reanimated": "~3.10.1",
83+
"react-native-reanimated": "~3.14.0",
8384
"react-native-redash": "^18.1.3",
8485
"react-native-root-siblings": "^5.0.1",
8586
"react-native-root-toast": "^3.6.0",
86-
"react-native-safe-area-context": "~4.10.1",
87-
"react-native-screens": "~3.31.1",
88-
"react-native-svg": "15.2.0",
89-
"react-native-url-polyfill": "^1.3.0",
90-
"react-native-web": "~0.19.10",
91-
"superjson": "2.2.1",
92-
"tailwind-merge": "^2.2.1",
93-
"tailwindcss": "3.4.1",
94-
"tailwindcss-animate": "^1.0.7",
87+
"react-native-safe-area-context": "~4.10.8",
88+
"react-native-screens": "~3.33.0",
89+
"react-native-svg": "15.4.0",
90+
"react-native-url-polyfill": "^2.0.0",
91+
"react-native-web": "~0.19.12",
92+
"superjson": "catalog:",
93+
"tailwind-merge": "^2.4.0",
94+
"tailwindcss": "catalog:tailwind",
95+
"tailwindcss-animate": "catalog:tailwind",
9596
"zeego": "^1.10.0",
96-
"zustand": "^4.5.2"
97+
"zustand": "^4.5.4"
9798
},
9899
"devDependencies": {
99-
"@babel/core": "^7.24.7",
100-
"@babel/preset-env": "^7.24.7",
101-
"@babel/runtime": "^7.24.7",
102-
"@expo/config-plugins": "^8.0.4",
100+
"@babel/core": "^7.25.2",
101+
"@babel/preset-env": "^7.25.3",
102+
"@babel/runtime": "^7.25.0",
103+
"@expo/config-plugins": "^8.0.8",
103104
"@hyper/api": "workspace:*",
104105
"@hyper/eslint-config": "workspace:*",
105106
"@hyper/prettier-config": "workspace:*",
106107
"@hyper/tailwind-config": "workspace:*",
107108
"@hyper/tsconfig": "workspace:*",
108-
"@testing-library/jest-dom": "^6.4.6",
109-
"@testing-library/react-native": "^12.5.1",
109+
"@testing-library/jest-dom": "^6.4.8",
110+
"@testing-library/react-native": "^12.5.2",
110111
"@types/babel__core": "^7.20.5",
111112
"@types/jest": "^29.5.12",
112-
"@types/node": "^20.12.10",
113+
"@types/node": "^20.14.10",
113114
"@types/react": "catalog:react18",
114115
"eslint": "catalog:",
115-
"jest": "^29.4.0",
116+
"jest": "^29.7.0",
116117
"jest-environment-jsdom": "^29.7.0",
117-
"jest-expo": "~51.0.1",
118+
"jest-expo": "~51.0.3",
118119
"jest-junit": "^16.0.0",
119120
"prettier": "catalog:",
120-
"react-test-renderer": "^18.2.0",
121-
"ts-jest": "^29.1.5",
121+
"react-test-renderer": "^18.3.1",
122+
"ts-jest": "^29.2.3",
122123
"typescript": "catalog:"
123124
},
124125
"prettier": "@hyper/prettier-config"

apps/expo/src/app/(app)/_layout.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { TouchableOpacity } from "react-native";
22
import { Stack } from "expo-router";
3-
import { useAuth } from "@clerk/clerk-expo";
3+
import {
4+
useSessionContext,
5+
useSupabaseClient,
6+
} from "@supabase/auth-helpers-react";
47

58
import { ThemeToggle } from "~/components/theme-toggle";
69
import { LogOut } from "~/lib/icons/log-out";
@@ -34,15 +37,16 @@ const Layout = () => {
3437
};
3538

3639
const SignOut = () => {
37-
const { isLoaded, signOut } = useAuth();
40+
const { isLoading } = useSessionContext();
41+
const supabase = useSupabaseClient();
3842

39-
if (!isLoaded) {
43+
if (isLoading) {
4044
return null;
4145
}
4246
return (
4347
<TouchableOpacity
44-
onPress={() => {
45-
signOut();
48+
onPress={async () => {
49+
await supabase.auth.signOut();
4650
}}
4751
>
4852
<LogOut size={23} strokeWidth={1.5} className="text-foreground" />

apps/expo/src/app/(app)/sandbox.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import Animated, {
55
FadeOutDown,
66
LayoutAnimationConfig,
77
} from "react-native-reanimated";
8-
import { SignedIn, useAuth } from "@clerk/clerk-expo";
8+
import {
9+
useSessionContext,
10+
useSupabaseClient,
11+
useUser,
12+
} from "@supabase/auth-helpers-react";
913

1014
import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar";
1115
import { Button } from "~/components/ui/button";
@@ -31,21 +35,24 @@ const GITHUB_AVATAR_URI =
3135

3236
export default function Screen() {
3337
const [progress, setProgress] = React.useState(78);
38+
const user = useUser();
3439

3540
function updateProgressValue() {
3641
setProgress(Math.floor(Math.random() * 100));
3742
}
3843

3944
const SignOut = () => {
40-
const { isLoaded, signOut } = useAuth();
41-
if (!isLoaded) {
45+
const { isLoading } = useSessionContext();
46+
const supabase = useSupabaseClient();
47+
48+
if (isLoading) {
4249
return null;
4350
}
4451
return (
4552
<View>
4653
<Button
47-
onPress={() => {
48-
signOut();
54+
onPress={async () => {
55+
await supabase.auth.signOut();
4956
}}
5057
>
5158
<Text>Sign Out</Text>
@@ -56,9 +63,7 @@ export default function Screen() {
5663

5764
return (
5865
<View className="flex-1 items-center justify-center gap-5 bg-secondary/30 p-6">
59-
<SignedIn>
60-
<SignOut />
61-
</SignedIn>
66+
{user?.id && <SignOut />}
6267
<Card className="w-full max-w-sm rounded-2xl p-6">
6368
<CardHeader className="items-center">
6469
<Avatar alt="Rick Sanchez's Avatar" className="h-24 w-24">

apps/expo/src/app/signin.tsx apps/expo/src/app/(auth)/signin.tsx

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
import { useState } from "react";
2-
import { Keyboard, ScrollView, TouchableWithoutFeedback } from "react-native";
2+
import {
3+
Alert,
4+
Keyboard,
5+
ScrollView,
6+
TouchableWithoutFeedback,
7+
} from "react-native";
38
import { AvoidSoftInputView } from "react-native-avoid-softinput";
49
import { SafeAreaView } from "react-native-safe-area-context";
5-
import { useSignIn } from "@clerk/clerk-expo";
10+
import {
11+
useSessionContext,
12+
useSupabaseClient,
13+
} from "@supabase/auth-helpers-react";
614

715
import type { SignInFormProps } from "~/components/auth/signin-form";
816
import { SignInForm } from "~/components/auth/signin-form";
917

1018
export default function SignInScreen() {
11-
const { signIn, setActive, isLoaded } = useSignIn();
19+
const { isLoading: isLoadingSession } = useSessionContext();
20+
const supabase = useSupabaseClient();
1221
const [isLoading, setIsLoading] = useState(false);
1322

1423
const onSubmit: SignInFormProps["onSubmit"] = async (data) => {
15-
if (!isLoaded) {
24+
if (isLoadingSession) {
1625
return;
1726
}
1827

1928
setIsLoading(true);
2029
try {
21-
const completeSignIn = await signIn.create({
22-
identifier: data.email,
30+
const { error } = await supabase.auth.signInWithPassword({
31+
email: data.email,
2332
password: data.password,
2433
});
25-
// This is an important step,
26-
// This indicates the user is signed in
27-
await setActive({ session: completeSignIn.createdSessionId });
34+
35+
if (error) {
36+
Alert.alert("Error", error.message);
37+
}
2838
} catch (err: unknown) {
2939
console.error(JSON.stringify(err, null, 2));
3040
} finally {

0 commit comments

Comments
 (0)