create-better-t-stack 3.1.7 → 3.1.8-canary.65dbf382

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