create-better-t-stack 3.8.3 → 3.9.0-pr730.0ee9844
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/README.md +17 -16
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-BCBL3cO2.mjs → src-DW15ZRe9.mjs} +80 -108
- package/package.json +44 -44
- package/templates/auth/better-auth/convex/backend/convex/auth.config.ts.hbs +5 -7
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +21 -19
- package/templates/auth/better-auth/convex/backend/convex/http.ts.hbs +6 -2
- package/templates/auth/better-auth/convex/native/base/lib/auth-client.ts.hbs +11 -6
- package/templates/auth/better-auth/convex/web/react/next/src/app/api/auth/[...all]/route.ts.hbs +2 -2
- package/templates/auth/better-auth/convex/web/react/next/src/components/user-menu.tsx.hbs +23 -20
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +13 -5
- package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/user-menu.tsx.hbs +25 -22
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/user-menu.tsx.hbs +23 -24
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs +11 -5
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs +4 -4
- package/templates/auth/better-auth/fullstack/tanstack-start/src/routes/api/auth/$.ts.hbs +6 -10
- package/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs +0 -1
- package/templates/auth/better-auth/web/react/next/src/components/user-menu.tsx.hbs +24 -21
- package/templates/auth/better-auth/web/react/react-router/src/components/user-menu.tsx.hbs +24 -21
- package/templates/auth/better-auth/web/react/{tanstack-start/src/components/user-menu.tsx → tanstack-router/src/components/user-menu.tsx.hbs} +26 -23
- package/templates/auth/better-auth/web/react/{tanstack-router/src/components/user-menu.tsx → tanstack-start/src/components/user-menu.tsx.hbs} +26 -23
- package/templates/frontend/react/next/package.json.hbs +8 -7
- package/templates/frontend/react/next/src/app/layout.tsx.hbs +28 -1
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +14 -4
- package/templates/frontend/react/react-router/package.json.hbs +2 -1
- package/templates/frontend/react/{tanstack-router/src/components/mode-toggle.tsx → react-router/src/components/mode-toggle.tsx.hbs} +1 -1
- package/templates/frontend/react/tanstack-router/package.json.hbs +2 -1
- package/templates/frontend/react/{react-router/src/components/mode-toggle.tsx → tanstack-router/src/components/mode-toggle.tsx.hbs} +1 -1
- package/templates/frontend/react/tanstack-start/package.json.hbs +2 -1
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +6 -0
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +13 -14
- package/templates/frontend/react/tanstack-start/vite.config.ts.hbs +5 -0
- package/templates/frontend/react/web-base/components.json +5 -2
- package/templates/frontend/react/web-base/src/components/ui/button.tsx.hbs +57 -0
- package/templates/frontend/react/web-base/src/components/ui/card.tsx.hbs +103 -0
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx.hbs +26 -0
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx.hbs +262 -0
- package/templates/frontend/react/web-base/src/components/ui/input.tsx.hbs +20 -0
- package/templates/frontend/react/web-base/src/components/ui/label.tsx.hbs +20 -0
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx.hbs +13 -0
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx.hbs +44 -0
- package/templates/frontend/react/web-base/src/index.css.hbs +57 -63
- package/templates/frontend/react/web-base/src/components/ui/button.tsx +0 -56
- package/templates/frontend/react/web-base/src/components/ui/card.tsx +0 -75
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx +0 -27
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx +0 -228
- package/templates/frontend/react/web-base/src/components/ui/input.tsx +0 -21
- package/templates/frontend/react/web-base/src/components/ui/label.tsx +0 -19
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx +0 -13
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx +0 -25
- /package/templates/auth/better-auth/web/react/tanstack-router/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-router/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-router/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/frontend/react/react-router/src/components/{theme-provider.tsx → theme-provider.tsx.hbs} +0 -0
- /package/templates/frontend/react/tanstack-router/src/components/{theme-provider.tsx → theme-provider.tsx.hbs} +0 -0
- /package/templates/frontend/react/web-base/src/lib/{utils.ts → utils.ts.hbs} +0 -0
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
import { createClient, type GenericCtx } from "@convex-dev/better-auth";
|
|
2
2
|
{{#if (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles"))}}
|
|
3
|
-
import { convex } from "@convex-dev/better-auth/plugins";
|
|
3
|
+
import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
|
|
4
4
|
import { expo } from "@better-auth/expo";
|
|
5
|
+
{{else if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
6
|
+
import { convex, crossDomain } from "@convex-dev/better-auth/plugins";
|
|
5
7
|
{{else}}
|
|
6
8
|
import { convex } from "@convex-dev/better-auth/plugins";
|
|
7
9
|
{{/if}}
|
|
8
|
-
{{#if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
9
|
-
import { crossDomain } from "@convex-dev/better-auth/plugins";
|
|
10
|
-
{{/if}}
|
|
11
10
|
import { components } from "./_generated/api";
|
|
12
11
|
import { DataModel } from "./_generated/dataModel";
|
|
13
12
|
import { query } from "./_generated/server";
|
|
14
13
|
import { betterAuth } from "better-auth";
|
|
15
14
|
import { v } from "convex/values";
|
|
15
|
+
import authConfig from "./auth.config";
|
|
16
16
|
|
|
17
|
-
{{#if (or (includes frontend "tanstack-start") (includes frontend "next")
|
|
17
|
+
{{#if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
|
|
18
|
+
const siteUrl = process.env.SITE_URL!;
|
|
19
|
+
{{else if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
18
20
|
const siteUrl = process.env.SITE_URL!;
|
|
19
21
|
{{/if}}
|
|
20
22
|
{{#if (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles"))}}
|
|
21
23
|
const nativeAppUrl = process.env.NATIVE_APP_URL || "mybettertapp://";
|
|
24
|
+
const nativeSiteUrl = process.env.NATIVE_SITE_URL || "http://localhost:8081";
|
|
22
25
|
{{/if}}
|
|
23
26
|
|
|
24
27
|
export const authComponent = createClient<DataModel>(components.betterAuth);
|
|
25
28
|
|
|
26
|
-
function createAuth(
|
|
27
|
-
ctx: GenericCtx<DataModel>,
|
|
28
|
-
{ optionsOnly }: { optionsOnly?: boolean } = { optionsOnly: false }
|
|
29
|
-
) {
|
|
29
|
+
function createAuth(ctx: GenericCtx<DataModel>) {
|
|
30
30
|
return betterAuth({
|
|
31
|
-
logger: {
|
|
32
|
-
disabled: optionsOnly,
|
|
33
|
-
},
|
|
34
31
|
{{#if (and (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles")) (or (includes frontend "tanstack-start") (includes frontend "next")))}}
|
|
35
32
|
baseURL: siteUrl,
|
|
36
|
-
trustedOrigins: [siteUrl, nativeAppUrl],
|
|
33
|
+
trustedOrigins: [siteUrl, nativeSiteUrl, nativeAppUrl],
|
|
34
|
+
{{else if (and (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles")) (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid")))}}
|
|
35
|
+
trustedOrigins: [siteUrl, nativeSiteUrl, nativeAppUrl],
|
|
37
36
|
{{else if (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles"))}}
|
|
38
|
-
trustedOrigins: [nativeAppUrl],
|
|
37
|
+
trustedOrigins: [nativeSiteUrl, nativeAppUrl],
|
|
39
38
|
{{else if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
|
|
40
39
|
baseURL: siteUrl,
|
|
41
40
|
trustedOrigins: [siteUrl],
|
|
42
|
-
{{else}}
|
|
41
|
+
{{else if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
43
42
|
trustedOrigins: [siteUrl],
|
|
44
43
|
{{/if}}
|
|
45
44
|
database: authComponent.adapter(ctx),
|
|
@@ -50,11 +49,14 @@ function createAuth(
|
|
|
50
49
|
plugins: [
|
|
51
50
|
{{#if (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles"))}}
|
|
52
51
|
expo(),
|
|
53
|
-
{
|
|
54
|
-
{{
|
|
52
|
+
crossDomain({ siteUrl: nativeSiteUrl }),
|
|
53
|
+
{{else if (or (includes frontend "tanstack-router") (includes frontend "react-router") (includes frontend "nuxt") (includes frontend "svelte") (includes frontend "solid"))}}
|
|
55
54
|
crossDomain({ siteUrl }),
|
|
56
55
|
{{/if}}
|
|
57
|
-
convex(
|
|
56
|
+
convex({
|
|
57
|
+
authConfig,
|
|
58
|
+
jwksRotateOnTokenGenerationError: true,
|
|
59
|
+
}),
|
|
58
60
|
],
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -67,4 +69,4 @@ export const getCurrentUser = query({
|
|
|
67
69
|
handler: async function (ctx, args) {
|
|
68
70
|
return authComponent.getAuthUser(ctx);
|
|
69
71
|
},
|
|
70
|
-
});
|
|
72
|
+
});
|
|
@@ -3,10 +3,14 @@ import { authComponent, createAuth } from "./auth";
|
|
|
3
3
|
|
|
4
4
|
const http = httpRouter();
|
|
5
5
|
|
|
6
|
-
{{#if (or (includes frontend "tanstack-start") (includes frontend "next")
|
|
6
|
+
{{#if (or (includes frontend "tanstack-start") (includes frontend "next"))}}
|
|
7
|
+
{{#if (or (includes frontend "native-bare") (includes frontend "native-uniwind") (includes frontend "native-unistyles"))}}
|
|
8
|
+
authComponent.registerRoutes(http, createAuth, { cors: true });
|
|
9
|
+
{{else}}
|
|
7
10
|
authComponent.registerRoutes(http, createAuth);
|
|
11
|
+
{{/if}}
|
|
8
12
|
{{else}}
|
|
9
13
|
authComponent.registerRoutes(http, createAuth, { cors: true });
|
|
10
14
|
{{/if}}
|
|
11
15
|
|
|
12
|
-
export default http;
|
|
16
|
+
export default http;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/react";
|
|
2
|
-
import { convexClient } from "@convex-dev/better-auth/client/plugins";
|
|
2
|
+
import { convexClient, crossDomainClient } from "@convex-dev/better-auth/client/plugins";
|
|
3
3
|
import { expoClient } from "@better-auth/expo/client";
|
|
4
4
|
import Constants from "expo-constants";
|
|
5
5
|
import * as SecureStore from "expo-secure-store";
|
|
6
|
+
import { Platform } from "react-native";
|
|
6
7
|
|
|
7
8
|
export const authClient = createAuthClient({
|
|
8
9
|
baseURL: process.env.EXPO_PUBLIC_CONVEX_SITE_URL,
|
|
9
10
|
plugins: [
|
|
10
|
-
expoClient({
|
|
11
|
-
scheme: Constants.expoConfig?.scheme as string,
|
|
12
|
-
storagePrefix: Constants.expoConfig?.scheme as string,
|
|
13
|
-
storage: SecureStore,
|
|
14
|
-
}),
|
|
15
11
|
convexClient(),
|
|
12
|
+
...(Platform.OS === "web"
|
|
13
|
+
? [crossDomainClient()]
|
|
14
|
+
: [
|
|
15
|
+
expoClient({
|
|
16
|
+
scheme: Constants.expoConfig?.scheme as string,
|
|
17
|
+
storagePrefix: Constants.expoConfig?.scheme as string,
|
|
18
|
+
storage: SecureStore,
|
|
19
|
+
}),
|
|
20
|
+
]),
|
|
16
21
|
],
|
|
17
22
|
});
|
package/templates/auth/better-auth/convex/web/react/next/src/app/api/auth/[...all]/route.ts.hbs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handler } from "@/lib/auth-server";
|
|
2
2
|
|
|
3
|
-
export const { GET, POST } =
|
|
3
|
+
export const { GET, POST } = handler;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
@@ -18,30 +19,32 @@ export default function UserMenu() {
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<DropdownMenu>
|
|
21
|
-
<DropdownMenuTrigger
|
|
22
|
+
<DropdownMenuTrigger>
|
|
22
23
|
<Button variant="outline">{user?.name}</Button>
|
|
23
24
|
</DropdownMenuTrigger>
|
|
24
25
|
<DropdownMenuContent className="bg-card">
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
<DropdownMenuGroup>
|
|
27
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
28
|
+
<DropdownMenuSeparator />
|
|
29
|
+
<DropdownMenuItem>{user?.email}</DropdownMenuItem>
|
|
30
|
+
<DropdownMenuItem>
|
|
31
|
+
<Button
|
|
32
|
+
variant="destructive"
|
|
33
|
+
className="w-full"
|
|
34
|
+
onClick={() => {
|
|
35
|
+
authClient.signOut({
|
|
36
|
+
fetchOptions: {
|
|
37
|
+
onSuccess: () => {
|
|
38
|
+
router.push("/dashboard");
|
|
39
|
+
},
|
|
37
40
|
},
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</
|
|
44
|
-
</
|
|
41
|
+
});
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
Sign Out
|
|
45
|
+
</Button>
|
|
46
|
+
</DropdownMenuItem>
|
|
47
|
+
</DropdownMenuGroup>
|
|
45
48
|
</DropdownMenuContent>
|
|
46
49
|
</DropdownMenu>
|
|
47
50
|
);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getToken as getTokenNextjs } from "@convex-dev/better-auth/nextjs";
|
|
1
|
+
import { convexBetterAuthNextJs } from "@convex-dev/better-auth/nextjs";
|
|
3
2
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const {
|
|
4
|
+
handler,
|
|
5
|
+
preloadAuthQuery,
|
|
6
|
+
isAuthenticated,
|
|
7
|
+
getToken,
|
|
8
|
+
fetchAuthQuery,
|
|
9
|
+
fetchAuthMutation,
|
|
10
|
+
fetchAuthAction,
|
|
11
|
+
} = convexBetterAuthNextJs({
|
|
12
|
+
convexUrl: process.env.NEXT_PUBLIC_CONVEX_URL!,
|
|
13
|
+
convexSiteUrl: process.env.NEXT_PUBLIC_CONVEX_SITE_URL!,
|
|
14
|
+
});
|
package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/user-menu.tsx.hbs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
@@ -18,32 +19,34 @@ export default function UserMenu() {
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<DropdownMenu>
|
|
21
|
-
<DropdownMenuTrigger
|
|
22
|
+
<DropdownMenuTrigger>
|
|
22
23
|
<Button variant="outline">{user?.name}</Button>
|
|
23
24
|
</DropdownMenuTrigger>
|
|
24
25
|
<DropdownMenuContent className="bg-card">
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
<DropdownMenuGroup>
|
|
27
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
28
|
+
<DropdownMenuSeparator />
|
|
29
|
+
<DropdownMenuItem>{user?.email}</DropdownMenuItem>
|
|
30
|
+
<DropdownMenuItem>
|
|
31
|
+
<Button
|
|
32
|
+
variant="destructive"
|
|
33
|
+
className="w-full"
|
|
34
|
+
onClick={() => {
|
|
35
|
+
authClient.signOut({
|
|
36
|
+
fetchOptions: {
|
|
37
|
+
onSuccess: () => {
|
|
38
|
+
navigate({
|
|
39
|
+
to: "/dashboard",
|
|
40
|
+
});
|
|
41
|
+
},
|
|
39
42
|
},
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</
|
|
46
|
-
</
|
|
43
|
+
});
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
Sign Out
|
|
47
|
+
</Button>
|
|
48
|
+
</DropdownMenuItem>
|
|
49
|
+
</DropdownMenuGroup>
|
|
47
50
|
</DropdownMenuContent>
|
|
48
51
|
</DropdownMenu>
|
|
49
52
|
);
|
package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/user-menu.tsx.hbs
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
7
8
|
DropdownMenuTrigger,
|
|
8
9
|
} from "@/components/ui/dropdown-menu";
|
|
9
10
|
import { authClient } from "@/lib/auth-client";
|
|
10
|
-
import { useNavigate } from "@tanstack/react-router";
|
|
11
11
|
import { Button } from "./ui/button";
|
|
12
12
|
import { useQuery } from "convex/react";
|
|
13
13
|
import { api } from "@{{projectName}}/backend/convex/_generated/api";
|
|
14
14
|
|
|
15
15
|
export default function UserMenu() {
|
|
16
|
-
const navigate = useNavigate();
|
|
17
16
|
const user = useQuery(api.auth.getCurrentUser)
|
|
18
17
|
|
|
19
18
|
return (
|
|
20
19
|
<DropdownMenu>
|
|
21
|
-
<DropdownMenuTrigger
|
|
20
|
+
<DropdownMenuTrigger>
|
|
22
21
|
<Button variant="outline">{user?.name}</Button>
|
|
23
22
|
</DropdownMenuTrigger>
|
|
24
23
|
<DropdownMenuContent className="bg-card">
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
24
|
+
<DropdownMenuGroup>
|
|
25
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
26
|
+
<DropdownMenuSeparator />
|
|
27
|
+
<DropdownMenuItem>{user?.email}</DropdownMenuItem>
|
|
28
|
+
<DropdownMenuItem>
|
|
29
|
+
<Button
|
|
30
|
+
variant="destructive"
|
|
31
|
+
className="w-full"
|
|
32
|
+
onClick={() => {
|
|
33
|
+
authClient.signOut({
|
|
34
|
+
fetchOptions: {
|
|
35
|
+
onSuccess: () => {
|
|
36
|
+
location.reload();
|
|
37
|
+
},
|
|
39
38
|
},
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</
|
|
46
|
-
</
|
|
39
|
+
});
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
Sign Out
|
|
43
|
+
</Button>
|
|
44
|
+
</DropdownMenuItem>
|
|
45
|
+
</DropdownMenuGroup>
|
|
47
46
|
</DropdownMenuContent>
|
|
48
47
|
</DropdownMenu>
|
|
49
48
|
);
|
package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { setupFetchClient } from "@convex-dev/better-auth/react-start";
|
|
3
|
-
import { getCookie } from "@tanstack/react-start/server";
|
|
1
|
+
import { convexBetterAuthReactStart } from "@convex-dev/better-auth/react-start";
|
|
4
2
|
|
|
5
|
-
export const {
|
|
6
|
-
|
|
3
|
+
export const {
|
|
4
|
+
handler,
|
|
5
|
+
getToken,
|
|
6
|
+
fetchAuthQuery,
|
|
7
|
+
fetchAuthMutation,
|
|
8
|
+
fetchAuthAction,
|
|
9
|
+
} = convexBetterAuthReactStart({
|
|
10
|
+
convexUrl: process.env.VITE_CONVEX_URL!,
|
|
11
|
+
convexSiteUrl: process.env.VITE_CONVEX_SITE_URL!,
|
|
12
|
+
});
|
package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { reactStartHandler } from "@convex-dev/better-auth/react-start";
|
|
2
1
|
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { handler } from "@/lib/auth-server";
|
|
3
3
|
|
|
4
4
|
export const Route = createFileRoute("/api/auth/$")({
|
|
5
5
|
server: {
|
|
6
6
|
handlers: {
|
|
7
|
-
GET: ({ request }) =>
|
|
8
|
-
POST: ({ request }) =>
|
|
7
|
+
GET: ({ request }) => handler(request),
|
|
8
|
+
POST: ({ request }) => handler(request),
|
|
9
9
|
},
|
|
10
10
|
},
|
|
11
|
-
});
|
|
11
|
+
});
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { handler } from "@/lib/auth-server";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute(
|
|
4
|
+
export const Route = createFileRoute("/api/auth/$")({
|
|
5
5
|
server: {
|
|
6
6
|
handlers: {
|
|
7
|
-
GET: ({ request }) =>
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
POST: ({ request }) => {
|
|
11
|
-
return auth.handler(request)
|
|
12
|
-
},
|
|
7
|
+
GET: ({ request }) => handler(request),
|
|
8
|
+
POST: ({ request }) => handler(request),
|
|
13
9
|
},
|
|
14
10
|
},
|
|
15
|
-
})
|
|
11
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
@@ -22,7 +23,7 @@ export default function UserMenu() {
|
|
|
22
23
|
|
|
23
24
|
if (!session) {
|
|
24
25
|
return (
|
|
25
|
-
<Button variant="outline"
|
|
26
|
+
<Button variant="outline">
|
|
26
27
|
<Link href="/login">Sign In</Link>
|
|
27
28
|
</Button>
|
|
28
29
|
);
|
|
@@ -30,30 +31,32 @@ export default function UserMenu() {
|
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<DropdownMenu>
|
|
33
|
-
<DropdownMenuTrigger
|
|
34
|
+
<DropdownMenuTrigger>
|
|
34
35
|
<Button variant="outline">{session.user.name}</Button>
|
|
35
36
|
</DropdownMenuTrigger>
|
|
36
37
|
<DropdownMenuContent className="bg-card">
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
<DropdownMenuGroup>
|
|
39
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
40
|
+
<DropdownMenuSeparator />
|
|
41
|
+
<DropdownMenuItem>{session.user.email}</DropdownMenuItem>
|
|
42
|
+
<DropdownMenuItem>
|
|
43
|
+
<Button
|
|
44
|
+
variant="destructive"
|
|
45
|
+
className="w-full"
|
|
46
|
+
onClick={() => {
|
|
47
|
+
authClient.signOut({
|
|
48
|
+
fetchOptions: {
|
|
49
|
+
onSuccess: () => {
|
|
50
|
+
router.push("/");
|
|
51
|
+
},
|
|
49
52
|
},
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
</
|
|
56
|
-
</
|
|
53
|
+
});
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Sign Out
|
|
57
|
+
</Button>
|
|
58
|
+
</DropdownMenuItem>
|
|
59
|
+
</DropdownMenuGroup>
|
|
57
60
|
</DropdownMenuContent>
|
|
58
61
|
</DropdownMenu>
|
|
59
62
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
@@ -22,7 +23,7 @@ export default function UserMenu() {
|
|
|
22
23
|
|
|
23
24
|
if (!session) {
|
|
24
25
|
return (
|
|
25
|
-
<Button variant="outline"
|
|
26
|
+
<Button variant="outline">
|
|
26
27
|
<Link to="/login">Sign In</Link>
|
|
27
28
|
</Button>
|
|
28
29
|
);
|
|
@@ -30,30 +31,32 @@ export default function UserMenu() {
|
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<DropdownMenu>
|
|
33
|
-
<DropdownMenuTrigger
|
|
34
|
+
<DropdownMenuTrigger>
|
|
34
35
|
<Button variant="outline">{session.user.name}</Button>
|
|
35
36
|
</DropdownMenuTrigger>
|
|
36
37
|
<DropdownMenuContent className="bg-card">
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
<DropdownMenuGroup>
|
|
39
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
40
|
+
<DropdownMenuSeparator />
|
|
41
|
+
<DropdownMenuItem>{session.user.email}</DropdownMenuItem>
|
|
42
|
+
<DropdownMenuItem>
|
|
43
|
+
<Button
|
|
44
|
+
variant="destructive"
|
|
45
|
+
className="w-full"
|
|
46
|
+
onClick={() => {
|
|
47
|
+
authClient.signOut({
|
|
48
|
+
fetchOptions: {
|
|
49
|
+
onSuccess: () => {
|
|
50
|
+
navigate("/");
|
|
51
|
+
},
|
|
49
52
|
},
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
</
|
|
56
|
-
</
|
|
53
|
+
});
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Sign Out
|
|
57
|
+
</Button>
|
|
58
|
+
</DropdownMenuItem>
|
|
59
|
+
</DropdownMenuGroup>
|
|
57
60
|
</DropdownMenuContent>
|
|
58
61
|
</DropdownMenu>
|
|
59
62
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DropdownMenu,
|
|
3
3
|
DropdownMenuContent,
|
|
4
|
+
DropdownMenuGroup,
|
|
4
5
|
DropdownMenuItem,
|
|
5
6
|
DropdownMenuLabel,
|
|
6
7
|
DropdownMenuSeparator,
|
|
@@ -22,7 +23,7 @@ export default function UserMenu() {
|
|
|
22
23
|
|
|
23
24
|
if (!session) {
|
|
24
25
|
return (
|
|
25
|
-
<Button variant="outline"
|
|
26
|
+
<Button variant="outline">
|
|
26
27
|
<Link to="/login">Sign In</Link>
|
|
27
28
|
</Button>
|
|
28
29
|
);
|
|
@@ -30,32 +31,34 @@ export default function UserMenu() {
|
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<DropdownMenu>
|
|
33
|
-
<DropdownMenuTrigger
|
|
34
|
+
<DropdownMenuTrigger>
|
|
34
35
|
<Button variant="outline">{session.user.name}</Button>
|
|
35
36
|
</DropdownMenuTrigger>
|
|
36
37
|
<DropdownMenuContent className="bg-card">
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
<DropdownMenuGroup>
|
|
39
|
+
<DropdownMenuLabel>My Account</DropdownMenuLabel>
|
|
40
|
+
<DropdownMenuSeparator />
|
|
41
|
+
<DropdownMenuItem>{session.user.email}</DropdownMenuItem>
|
|
42
|
+
<DropdownMenuItem>
|
|
43
|
+
<Button
|
|
44
|
+
variant="destructive"
|
|
45
|
+
className="w-full"
|
|
46
|
+
onClick={() => {
|
|
47
|
+
authClient.signOut({
|
|
48
|
+
fetchOptions: {
|
|
49
|
+
onSuccess: () => {
|
|
50
|
+
navigate({
|
|
51
|
+
to: "/",
|
|
52
|
+
});
|
|
53
|
+
},
|
|
51
54
|
},
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
</
|
|
58
|
-
</
|
|
55
|
+
});
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
Sign Out
|
|
59
|
+
</Button>
|
|
60
|
+
</DropdownMenuItem>
|
|
61
|
+
</DropdownMenuGroup>
|
|
59
62
|
</DropdownMenuContent>
|
|
60
63
|
</DropdownMenu>
|
|
61
64
|
);
|