create-better-t-stack 3.1.8 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-DeOVz-ZI.js → src-JAo0_3IZ.js} +73 -17
- package/package.json +1 -1
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +55 -34
- package/templates/auth/better-auth/convex/backend/convex/http.ts.hbs +1 -1
- package/templates/auth/better-auth/convex/native/base/lib/auth-client.ts.hbs +19 -0
- package/templates/auth/better-auth/convex/native/nativewind/components/sign-in.tsx.hbs +86 -0
- package/templates/auth/better-auth/convex/native/nativewind/components/sign-up.tsx.hbs +97 -0
- package/templates/auth/better-auth/convex/native/unistyles/components/sign-in.tsx.hbs +127 -0
- package/templates/auth/better-auth/convex/native/unistyles/components/sign-up.tsx.hbs +145 -0
- package/templates/auth/better-auth/native/{native-base → base}/lib/auth-client.ts.hbs +3 -2
- package/templates/frontend/native/nativewind/app/(drawer)/index.tsx.hbs +127 -76
- package/templates/frontend/native/nativewind/app/_layout.tsx.hbs +21 -0
- package/templates/frontend/native/unistyles/app/(drawer)/index.tsx.hbs +160 -51
- package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +28 -0
- package/templates/frontend/native/unistyles/app.json.hbs +1 -1
- /package/templates/frontend/native/{native-base → base}/assets/images/android-icon-background.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/android-icon-foreground.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/android-icon-monochrome.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/favicon.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/icon.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/partial-react-logo.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/react-logo.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/react-logo@2x.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/react-logo@3x.png +0 -0
- /package/templates/frontend/native/{native-base → base}/assets/images/splash-icon.png +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScrollView, Text, View } from "react-native";
|
|
1
|
+
import { ScrollView, Text, View, TouchableOpacity } from "react-native";
|
|
2
2
|
import { StyleSheet } from "react-native-unistyles";
|
|
3
3
|
import { Container } from "@/components/container";
|
|
4
4
|
|
|
@@ -10,18 +10,22 @@ import { orpc } from "@/utils/orpc";
|
|
|
10
10
|
import { useQuery } from "@tanstack/react-query";
|
|
11
11
|
import { trpc } from "@/utils/trpc";
|
|
12
12
|
{{/if}}
|
|
13
|
-
{{#if (eq backend "convex")}}
|
|
14
|
-
{{#if (eq auth "clerk")}}
|
|
13
|
+
{{#if (and (eq backend "convex") (eq auth "clerk"))}}
|
|
15
14
|
import { Link } from "expo-router";
|
|
16
15
|
import { Authenticated, AuthLoading, Unauthenticated, useQuery } from "convex/react";
|
|
17
16
|
import { api } from "@{{ projectName }}/backend/convex/_generated/api";
|
|
18
17
|
import { useUser } from "@clerk/clerk-expo";
|
|
19
18
|
import { SignOutButton } from "@/components/sign-out-button";
|
|
20
|
-
{{else}}
|
|
19
|
+
{{else if (and (eq backend "convex") (eq auth "better-auth"))}}
|
|
20
|
+
import { useConvexAuth, useQuery } from "convex/react";
|
|
21
|
+
import { api } from "@{{ projectName }}/backend/convex/_generated/api";
|
|
22
|
+
import { authClient } from "@/lib/auth-client";
|
|
23
|
+
import { SignIn } from "@/components/sign-in";
|
|
24
|
+
import { SignUp } from "@/components/sign-up";
|
|
25
|
+
{{else if (eq backend "convex")}}
|
|
21
26
|
import { useQuery } from "convex/react";
|
|
22
27
|
import { api } from "@{{ projectName }}/backend/convex/_generated/api";
|
|
23
28
|
{{/if}}
|
|
24
|
-
{{/if}}
|
|
25
29
|
|
|
26
30
|
export default function Home() {
|
|
27
31
|
{{#if (eq api "orpc")}}
|
|
@@ -30,14 +34,16 @@ export default function Home() {
|
|
|
30
34
|
{{#if (eq api "trpc")}}
|
|
31
35
|
const healthCheck = useQuery(trpc.healthCheck.queryOptions());
|
|
32
36
|
{{/if}}
|
|
33
|
-
{{#if (eq backend "convex")}}
|
|
34
|
-
{{#if (eq auth "clerk")}}
|
|
37
|
+
{{#if (and (eq backend "convex") (eq auth "clerk"))}}
|
|
35
38
|
const { user } = useUser();
|
|
36
39
|
const healthCheck = useQuery(api.healthCheck.get);
|
|
37
40
|
const privateData = useQuery(api.privateData.get);
|
|
38
|
-
{{else}}
|
|
41
|
+
{{else if (and (eq backend "convex") (eq auth "better-auth"))}}
|
|
42
|
+
const healthCheck = useQuery(api.healthCheck.get);
|
|
43
|
+
const { isAuthenticated } = useConvexAuth();
|
|
44
|
+
const user = useQuery(api.auth.getCurrentUser, isAuthenticated ? {} : "skip");
|
|
45
|
+
{{else if (eq backend "convex")}}
|
|
39
46
|
const healthCheck = useQuery(api.healthCheck.get);
|
|
40
|
-
{{/if}}
|
|
41
47
|
{{/if}}
|
|
42
48
|
|
|
43
49
|
return (
|
|
@@ -46,7 +52,11 @@ export default function Home() {
|
|
|
46
52
|
contentContainerStyle={styles.container}
|
|
47
53
|
showsVerticalScrollIndicator={false}
|
|
48
54
|
>
|
|
49
|
-
<Text style={styles.heroTitle}>
|
|
55
|
+
<Text style={styles.heroTitle}>
|
|
56
|
+
BETTER T STACK
|
|
57
|
+
</Text>
|
|
58
|
+
|
|
59
|
+
{{#unless (and (eq backend "convex") (eq auth "better-auth"))}}
|
|
50
60
|
<View style={styles.statusCard}>
|
|
51
61
|
<View style={styles.statusHeader}>
|
|
52
62
|
<Text style={styles.statusTitle}>System Status</Text>
|
|
@@ -54,28 +64,29 @@ export default function Home() {
|
|
|
54
64
|
<Text style={styles.statusBadgeText}>LIVE</Text>
|
|
55
65
|
</View>
|
|
56
66
|
</View>
|
|
57
|
-
|
|
58
67
|
{{#if (eq backend "convex")}}
|
|
59
|
-
|
|
60
|
-
<View
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
{{#unless (eq auth "better-auth")}}
|
|
69
|
+
<View style={styles.statusRow}>
|
|
70
|
+
<View
|
|
71
|
+
style={[
|
|
72
|
+
styles.statusDot,
|
|
73
|
+
healthCheck === "OK"
|
|
74
|
+
? styles.statusDotSuccess
|
|
75
|
+
: styles.statusDotWarning,
|
|
76
|
+
]}
|
|
77
|
+
/>
|
|
78
|
+
<View style={styles.statusContent}>
|
|
79
|
+
<Text style={styles.statusLabel}>Convex</Text>
|
|
80
|
+
<Text style={styles.statusDescription}>
|
|
81
|
+
{healthCheck === undefined
|
|
82
|
+
? "Checking connection..."
|
|
83
|
+
: healthCheck === "OK"
|
|
84
|
+
? "Connected to API"
|
|
85
|
+
: "API Disconnected"}
|
|
86
|
+
</Text>
|
|
87
|
+
</View>
|
|
77
88
|
</View>
|
|
78
|
-
|
|
89
|
+
{{/unless}}
|
|
79
90
|
{{else}}
|
|
80
91
|
{{#unless (eq api "none")}}
|
|
81
92
|
<View style={styles.statusRow}>
|
|
@@ -89,38 +100,31 @@ export default function Home() {
|
|
|
89
100
|
/>
|
|
90
101
|
<View style={styles.statusContent}>
|
|
91
102
|
<Text style={styles.statusLabel}>
|
|
92
|
-
{{#if (eq api "orpc")}}
|
|
93
|
-
|
|
94
|
-
{{/if}}
|
|
95
|
-
{{#if (eq api "trpc")}}
|
|
96
|
-
TRPC
|
|
97
|
-
{{/if}}
|
|
103
|
+
{{#if (eq api "orpc")}}ORPC{{/if}}
|
|
104
|
+
{{#if (eq api "trpc")}}TRPC{{/if}}
|
|
98
105
|
</Text>
|
|
99
106
|
<Text style={styles.statusDescription}>
|
|
100
|
-
{{#if (eq api "orpc")}}
|
|
101
107
|
{healthCheck.isLoading
|
|
102
108
|
? "Checking connection..."
|
|
103
109
|
: healthCheck.data
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{{/if}}
|
|
107
|
-
{{#if (eq api "trpc")}}
|
|
108
|
-
{healthCheck.isLoading
|
|
109
|
-
? "Checking connection..."
|
|
110
|
-
: healthCheck.data
|
|
111
|
-
? "All systems operational"
|
|
112
|
-
: "Service unavailable"}
|
|
113
|
-
{{/if}}
|
|
110
|
+
? "Connected to API"
|
|
111
|
+
: "API Disconnected"}
|
|
114
112
|
</Text>
|
|
115
113
|
</View>
|
|
116
114
|
</View>
|
|
117
115
|
{{/unless}}
|
|
118
116
|
{{/if}}
|
|
119
117
|
</View>
|
|
118
|
+
{{/unless}}
|
|
119
|
+
|
|
120
120
|
{{#if (and (eq backend "convex") (eq auth "clerk"))}}
|
|
121
121
|
<Authenticated>
|
|
122
|
-
<Text>
|
|
123
|
-
|
|
122
|
+
<Text>
|
|
123
|
+
Hello {user?.emailAddresses[0].emailAddress}
|
|
124
|
+
</Text>
|
|
125
|
+
<Text>
|
|
126
|
+
Private Data: {privateData?.message}
|
|
127
|
+
</Text>
|
|
124
128
|
<SignOutButton />
|
|
125
129
|
</Authenticated>
|
|
126
130
|
<Unauthenticated>
|
|
@@ -135,6 +139,54 @@ export default function Home() {
|
|
|
135
139
|
<Text>Loading...</Text>
|
|
136
140
|
</AuthLoading>
|
|
137
141
|
{{/if}}
|
|
142
|
+
|
|
143
|
+
{{#if (and (eq backend "convex") (eq auth "better-auth"))}}
|
|
144
|
+
{user ? (
|
|
145
|
+
<View style={styles.userCard}>
|
|
146
|
+
<View style={styles.userHeader}>
|
|
147
|
+
<Text style={styles.userWelcome}>
|
|
148
|
+
Welcome,{" "}
|
|
149
|
+
<Text style={styles.userName}>{user.name}</Text>
|
|
150
|
+
</Text>
|
|
151
|
+
</View>
|
|
152
|
+
<Text style={styles.userEmail}>{user.email}</Text>
|
|
153
|
+
<TouchableOpacity
|
|
154
|
+
style={styles.signOutButton}
|
|
155
|
+
onPress={() => {
|
|
156
|
+
authClient.signOut();
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<Text style={styles.signOutText}>Sign Out</Text>
|
|
160
|
+
</TouchableOpacity>
|
|
161
|
+
</View>
|
|
162
|
+
) : null}
|
|
163
|
+
<View style={styles.apiStatusCard}>
|
|
164
|
+
<Text style={styles.apiStatusTitle}>API Status</Text>
|
|
165
|
+
<View style={styles.apiStatusRow}>
|
|
166
|
+
<View
|
|
167
|
+
style={[
|
|
168
|
+
styles.statusDot,
|
|
169
|
+
healthCheck === "OK"
|
|
170
|
+
? styles.statusDotSuccess
|
|
171
|
+
: styles.statusDotWarning,
|
|
172
|
+
]}
|
|
173
|
+
/>
|
|
174
|
+
<Text style={styles.apiStatusText}>
|
|
175
|
+
{healthCheck === undefined
|
|
176
|
+
? "Checking..."
|
|
177
|
+
: healthCheck === "OK"
|
|
178
|
+
? "Connected to API"
|
|
179
|
+
: "API Disconnected"}
|
|
180
|
+
</Text>
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
{!user && (
|
|
184
|
+
<>
|
|
185
|
+
<SignIn />
|
|
186
|
+
<SignUp />
|
|
187
|
+
</>
|
|
188
|
+
)}
|
|
189
|
+
{{/if}}
|
|
138
190
|
</ScrollView>
|
|
139
191
|
</Container>
|
|
140
192
|
);
|
|
@@ -220,5 +272,62 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
220
272
|
statusDescription: {
|
|
221
273
|
fontSize: theme.fontSize.xs,
|
|
222
274
|
color: theme.colors.mutedForeground,
|
|
223
|
-
}
|
|
224
|
-
|
|
275
|
+
},
|
|
276
|
+
userCard: {
|
|
277
|
+
backgroundColor: theme.colors.card,
|
|
278
|
+
borderWidth: 1,
|
|
279
|
+
borderColor: theme.colors.border,
|
|
280
|
+
borderRadius: theme.borderRadius.lg,
|
|
281
|
+
padding: theme.spacing.md,
|
|
282
|
+
marginBottom: theme.spacing.md,
|
|
283
|
+
},
|
|
284
|
+
userHeader: {
|
|
285
|
+
flexDirection: "row",
|
|
286
|
+
justifyContent: "space-between",
|
|
287
|
+
alignItems: "center",
|
|
288
|
+
marginBottom: theme.spacing.xs,
|
|
289
|
+
},
|
|
290
|
+
userWelcome: {
|
|
291
|
+
fontSize: theme.fontSize.base,
|
|
292
|
+
color: theme.colors.foreground,
|
|
293
|
+
},
|
|
294
|
+
userName: {
|
|
295
|
+
fontWeight: "500",
|
|
296
|
+
},
|
|
297
|
+
userEmail: {
|
|
298
|
+
fontSize: theme.fontSize.sm,
|
|
299
|
+
color: theme.colors.mutedForeground,
|
|
300
|
+
marginBottom: theme.spacing.md,
|
|
301
|
+
},
|
|
302
|
+
signOutButton: {
|
|
303
|
+
backgroundColor: theme.colors.destructive,
|
|
304
|
+
paddingVertical: theme.spacing.sm,
|
|
305
|
+
paddingHorizontal: theme.spacing.md,
|
|
306
|
+
borderRadius: theme.borderRadius.md,
|
|
307
|
+
alignSelf: "flex-start",
|
|
308
|
+
},
|
|
309
|
+
signOutText: {
|
|
310
|
+
color: theme.colors.destructiveForeground,
|
|
311
|
+
fontWeight: "500",
|
|
312
|
+
},
|
|
313
|
+
apiStatusCard: {
|
|
314
|
+
marginBottom: theme.spacing.md,
|
|
315
|
+
borderRadius: theme.borderRadius.lg,
|
|
316
|
+
borderWidth: 1,
|
|
317
|
+
borderColor: theme.colors.border,
|
|
318
|
+
padding: theme.spacing.md,
|
|
319
|
+
},
|
|
320
|
+
apiStatusTitle: {
|
|
321
|
+
marginBottom: theme.spacing.sm,
|
|
322
|
+
fontWeight: "500",
|
|
323
|
+
color: theme.colors.foreground,
|
|
324
|
+
},
|
|
325
|
+
apiStatusRow: {
|
|
326
|
+
flexDirection: "row",
|
|
327
|
+
alignItems: "center",
|
|
328
|
+
gap: theme.spacing.xs,
|
|
329
|
+
},
|
|
330
|
+
apiStatusText: {
|
|
331
|
+
color: theme.colors.mutedForeground,
|
|
332
|
+
},
|
|
333
|
+
}));
|
|
@@ -8,7 +8,13 @@ import { queryClient } from "@/utils/trpc";
|
|
|
8
8
|
import { queryClient } from "@/utils/orpc";
|
|
9
9
|
{{/if}}
|
|
10
10
|
{{#if (eq backend "convex")}}
|
|
11
|
+
{{#if (eq auth "better-auth")}}
|
|
12
|
+
import { ConvexReactClient } from "convex/react";
|
|
13
|
+
import { ConvexBetterAuthProvider } from "@convex-dev/better-auth/react";
|
|
14
|
+
import { authClient } from "@/lib/auth-client";
|
|
15
|
+
{{else}}
|
|
11
16
|
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
17
|
+
{{/if}}
|
|
12
18
|
{{#if (eq auth "clerk")}}
|
|
13
19
|
import { ClerkProvider, useAuth } from "@clerk/clerk-expo";
|
|
14
20
|
import { ConvexProviderWithClerk } from "convex/react-clerk";
|
|
@@ -67,6 +73,28 @@ export default function RootLayout() {
|
|
|
67
73
|
</GestureHandlerRootView>
|
|
68
74
|
</ConvexProviderWithClerk>
|
|
69
75
|
</ClerkProvider>
|
|
76
|
+
{{else if (eq auth "better-auth")}}
|
|
77
|
+
<ConvexBetterAuthProvider client={convex} authClient={authClient}>
|
|
78
|
+
<GestureHandlerRootView style=\{{ flex: 1 }}>
|
|
79
|
+
<Stack
|
|
80
|
+
screenOptions=\{{
|
|
81
|
+
headerStyle: {
|
|
82
|
+
backgroundColor: theme.colors.background,
|
|
83
|
+
},
|
|
84
|
+
headerTitleStyle: {
|
|
85
|
+
color: theme.colors.foreground,
|
|
86
|
+
},
|
|
87
|
+
headerTintColor: theme.colors.foreground,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Stack.Screen name="(drawer)" options=\{{ headerShown: false }} />
|
|
91
|
+
<Stack.Screen
|
|
92
|
+
name="modal"
|
|
93
|
+
options=\{{ title: "Modal", presentation: "modal" }}
|
|
94
|
+
/>
|
|
95
|
+
</Stack>
|
|
96
|
+
</GestureHandlerRootView>
|
|
97
|
+
</ConvexBetterAuthProvider>
|
|
70
98
|
{{else}}
|
|
71
99
|
<ConvexProvider client={convex}>
|
|
72
100
|
<GestureHandlerRootView style=\{{ flex: 1 }}>
|
/package/templates/frontend/native/{native-base → base}/assets/images/android-icon-background.png
RENAMED
|
File without changes
|
/package/templates/frontend/native/{native-base → base}/assets/images/android-icon-foreground.png
RENAMED
|
File without changes
|
/package/templates/frontend/native/{native-base → base}/assets/images/android-icon-monochrome.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/frontend/native/{native-base → base}/assets/images/partial-react-logo.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|