create-better-t-stack 2.45.4 → 2.46.0-canary.85c43fef

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 (75) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +1 -1
  4. package/dist/{src-Cun9EO6e.js → src-lN80CwOs.js} +396 -162
  5. package/package.json +1 -1
  6. package/templates/auth/better-auth/convex/backend/convex/auth.config.ts.hbs +8 -0
  7. package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +48 -0
  8. package/templates/auth/better-auth/convex/backend/convex/convex.config.ts.hbs +7 -0
  9. package/templates/auth/better-auth/convex/backend/convex/http.ts.hbs +12 -0
  10. package/templates/auth/better-auth/convex/backend/convex/privateData.ts.hbs +16 -0
  11. package/templates/auth/better-auth/convex/web/react/next/src/app/api/auth/[...all]/route.ts.hbs +3 -0
  12. package/templates/auth/better-auth/convex/web/react/next/src/app/dashboard/page.tsx.hbs +40 -0
  13. package/templates/auth/better-auth/convex/web/react/next/src/components/sign-in-form.tsx.hbs +129 -0
  14. package/templates/auth/better-auth/convex/web/react/next/src/components/sign-up-form.tsx.hbs +154 -0
  15. package/templates/auth/better-auth/convex/web/react/next/src/components/user-menu.tsx.hbs +48 -0
  16. package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-client.ts.hbs +6 -0
  17. package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +6 -0
  18. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/lib/auth-client.ts.hbs +10 -0
  19. package/templates/auth/better-auth/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +43 -0
  20. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/sign-in-form.tsx.hbs +133 -0
  21. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/sign-up-form.tsx.hbs +158 -0
  22. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/user-menu.tsx.hbs +50 -0
  23. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-client.ts.hbs +6 -0
  24. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs +5 -0
  25. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs +11 -0
  26. package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +43 -0
  27. package/templates/auth/better-auth/server/base/src/lib/auth.ts.hbs +163 -16
  28. package/templates/auth/better-auth/web/nuxt/app/pages/dashboard.vue.hbs +36 -2
  29. package/templates/auth/better-auth/web/nuxt/app/plugins/auth-client.ts.hbs +22 -0
  30. package/templates/auth/better-auth/web/react/base/src/lib/auth-client.ts.hbs +6 -0
  31. package/templates/auth/better-auth/web/react/next/src/app/dashboard/dashboard.tsx.hbs +58 -0
  32. package/templates/auth/better-auth/web/react/next/src/app/dashboard/page.tsx.hbs +31 -41
  33. package/templates/auth/better-auth/web/react/react-router/src/routes/dashboard.tsx.hbs +37 -3
  34. package/templates/auth/better-auth/web/react/tanstack-router/src/routes/dashboard.tsx.hbs +50 -32
  35. package/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +51 -36
  36. package/templates/auth/better-auth/web/solid/src/lib/auth-client.ts.hbs +11 -0
  37. package/templates/auth/better-auth/web/solid/src/routes/dashboard.tsx.hbs +52 -29
  38. package/templates/auth/better-auth/web/svelte/src/lib/{auth-client.ts → auth-client.ts.hbs} +6 -0
  39. package/templates/auth/better-auth/web/svelte/src/routes/dashboard/+page.svelte.hbs +24 -3
  40. package/templates/backend/server/server-base/package.json.hbs +1 -1
  41. package/templates/extras/bunfig.toml.hbs +4 -0
  42. package/templates/frontend/react/next/src/components/providers.tsx.hbs +8 -0
  43. package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +8 -1
  44. package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +51 -0
  45. package/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs +2 -2
  46. package/templates/frontend/react/web-base/src/components/header.tsx.hbs +2 -2
  47. package/templates/frontend/solid/package.json.hbs +10 -10
  48. package/templates/payments/polar/server/base/src/lib/payments.ts.hbs +6 -0
  49. package/templates/payments/polar/web/nuxt/app/pages/success.vue.hbs +11 -0
  50. package/templates/payments/polar/web/react/next/src/app/success/page.tsx.hbs +15 -0
  51. package/templates/payments/polar/web/react/react-router/src/routes/success.tsx.hbs +13 -0
  52. package/templates/payments/polar/web/react/tanstack-router/src/routes/success.tsx.hbs +19 -0
  53. package/templates/payments/polar/web/react/tanstack-start/src/routes/success.tsx.hbs +19 -0
  54. package/templates/payments/polar/web/solid/src/routes/success.tsx.hbs +23 -0
  55. package/templates/payments/polar/web/svelte/src/routes/success/+page.svelte.hbs +12 -0
  56. package/templates/auth/better-auth/web/nuxt/app/plugins/auth-client.ts +0 -16
  57. package/templates/auth/better-auth/web/react/next/src/components/theme-provider.tsx +0 -11
  58. package/templates/auth/better-auth/web/solid/src/lib/auth-client.ts +0 -5
  59. /package/templates/auth/better-auth/web/nuxt/app/components/{SignInForm.vue → SignInForm.vue.hbs} +0 -0
  60. /package/templates/auth/better-auth/web/nuxt/app/components/{SignUpForm.vue → SignUpForm.vue.hbs} +0 -0
  61. /package/templates/auth/better-auth/web/nuxt/app/components/{UserMenu.vue → UserMenu.vue.hbs} +0 -0
  62. /package/templates/auth/better-auth/web/nuxt/app/pages/{login.vue → login.vue.hbs} +0 -0
  63. /package/templates/auth/better-auth/web/react/next/src/app/login/{page.tsx → page.tsx.hbs} +0 -0
  64. /package/templates/auth/better-auth/web/react/next/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
  65. /package/templates/auth/better-auth/web/react/next/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
  66. /package/templates/auth/better-auth/web/react/next/src/components/{user-menu.tsx → user-menu.tsx.hbs} +0 -0
  67. /package/templates/auth/better-auth/web/react/react-router/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
  68. /package/templates/auth/better-auth/web/react/react-router/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
  69. /package/templates/auth/better-auth/web/react/react-router/src/components/{user-menu.tsx → user-menu.tsx.hbs} +0 -0
  70. /package/templates/auth/better-auth/web/react/react-router/src/routes/{login.tsx → login.tsx.hbs} +0 -0
  71. /package/templates/auth/better-auth/web/svelte/src/components/{SignInForm.svelte → SignInForm.svelte.hbs} +0 -0
  72. /package/templates/auth/better-auth/web/svelte/src/components/{SignUpForm.svelte → SignUpForm.svelte.hbs} +0 -0
  73. /package/templates/auth/better-auth/web/svelte/src/components/{UserMenu.svelte → UserMenu.svelte.hbs} +0 -0
  74. /package/templates/auth/better-auth/web/svelte/src/routes/login/{+page.svelte → +page.svelte.hbs} +0 -0
  75. /package/templates/frontend/react/web-base/src/components/{loader.tsx → loader.tsx.hbs} +0 -0
@@ -8,7 +8,9 @@ import {
8
8
  Scripts,
9
9
  createRootRouteWithContext,
10
10
  useRouterState,
11
+ {{#if (and (eq backend "convex") (or (eq auth "clerk") (eq auth "better-auth")))}}
11
12
  useRouteContext,
13
+ {{/if}}
12
14
  } from "@tanstack/react-router";
13
15
  import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
14
16
  import Header from "../components/header";
@@ -17,6 +19,10 @@ import appCss from "../index.css?url";
17
19
  import type { QueryClient } from "@tanstack/react-query";
18
20
  import type { ConvexQueryClient } from "@convex-dev/react-query";
19
21
  import type { ConvexReactClient } from "convex/react";
22
+ {{else}}
23
+ {{#if (or (eq api "trpc") (eq api "orpc"))}}
24
+ import type { QueryClient } from "@tanstack/react-query";
25
+ {{/if}}
20
26
  {{/if}}
21
27
  import Loader from "@/components/loader";
22
28
 
@@ -32,6 +38,23 @@ const fetchClerkAuth = createServerFn({ method: "GET" }).handler(async () => {
32
38
  const token = await auth.getToken({ template: "convex" });
33
39
  return { userId: auth.userId, token };
34
40
  });
41
+ {{else if (and (eq backend "convex") (eq auth "better-auth"))}}
42
+ import { createServerFn } from "@tanstack/react-start";
43
+ import { getWebRequest, getCookie } from "@tanstack/react-start/server";
44
+ import { ConvexBetterAuthProvider } from "@convex-dev/better-auth/react";
45
+ import { fetchSession, getCookieName } from "@convex-dev/better-auth/react-start";
46
+ import { authClient } from "@/lib/auth-client";
47
+ import { createAuth } from "@{{projectName}}/backend/convex/auth";
48
+
49
+ const fetchAuth = createServerFn({ method: "GET" }).handler(async () => {
50
+ const { session } = await fetchSession(getWebRequest());
51
+ const sessionCookieName = getCookieName(createAuth);
52
+ const token = getCookie(sessionCookieName);
53
+ return {
54
+ userId: session?.user.id,
55
+ token,
56
+ };
57
+ });
35
58
  {{/if}}
36
59
 
37
60
  {{#if (eq backend "convex")}}
@@ -91,6 +114,14 @@ export const Route = createRootRouteWithContext<RouterAppContext>()({
91
114
  }
92
115
  return { userId, token };
93
116
  },
117
+ {{else if (and (eq backend "convex") (eq auth "better-auth"))}}
118
+ beforeLoad: async (ctx) => {
119
+ const { userId, token } = await fetchAuth();
120
+ if (token) {
121
+ ctx.context.convexQueryClient.serverHttpClient?.setAuth(token);
122
+ }
123
+ return { userId, token };
124
+ },
94
125
  {{/if}}
95
126
  });
96
127
 
@@ -118,6 +149,26 @@ function RootDocument() {
118
149
  </ConvexProviderWithClerk>
119
150
  </ClerkProvider>
120
151
  );
152
+ {{else if (and (eq backend "convex") (eq auth "better-auth"))}}
153
+ const context = useRouteContext({ from: Route.id });
154
+ return (
155
+ <ConvexBetterAuthProvider client={context.convexClient} authClient={authClient}>
156
+ <html lang="en" className="dark">
157
+ <head>
158
+ <HeadContent />
159
+ </head>
160
+ <body>
161
+ <div className="grid h-svh grid-rows-[auto_1fr]">
162
+ <Header />
163
+ {isFetching ? <Loader /> : <Outlet />}
164
+ </div>
165
+ <Toaster richColors />
166
+ <TanStackRouterDevtools position="bottom-left" />
167
+ <Scripts />
168
+ </body>
169
+ </html>
170
+ </ConvexBetterAuthProvider>
171
+ );
121
172
  {{else}}
122
173
  return (
123
174
  <html lang="en" className="dark">
@@ -1,7 +1,7 @@
1
1
  import { createFileRoute } from "@tanstack/react-router";
2
2
  {{#if (eq backend "convex")}}
3
3
  import { convexQuery } from "@convex-dev/react-query";
4
- import { useSuspenseQuery } from "@tanstack/react-query";
4
+ import { useQuery } from "@tanstack/react-query";
5
5
  import { api } from "@{{projectName}}/backend/convex/_generated/api";
6
6
  {{else if (or (eq api "trpc") (eq api "orpc"))}}
7
7
  import { useQuery } from "@tanstack/react-query";
@@ -35,7 +35,7 @@ const TITLE_TEXT = `
35
35
 
36
36
  function HomeComponent() {
37
37
  {{#if (eq backend "convex")}}
38
- const healthCheck = useSuspenseQuery(convexQuery(api.healthCheck.get, {}));
38
+ const healthCheck = useQuery(convexQuery(api.healthCheck.get, {}));
39
39
  {{else if (eq api "trpc")}}
40
40
  const trpc = useTRPC();
41
41
  const healthCheck = useQuery(trpc.healthCheck.queryOptions());
@@ -9,7 +9,7 @@ import { Link } from "@tanstack/react-router";
9
9
  {{#unless (includes frontend "tanstack-start")}}
10
10
  import { ModeToggle } from "./mode-toggle";
11
11
  {{/unless}}
12
- {{#if (eq auth "better-auth")}}
12
+ {{#if (and (eq auth "better-auth") (ne backend "convex"))}}
13
13
  import UserMenu from "./user-menu";
14
14
  {{/if}}
15
15
 
@@ -67,7 +67,7 @@ export default function Header() {
67
67
  {{#unless (includes frontend "tanstack-start")}}
68
68
  <ModeToggle />
69
69
  {{/unless}}
70
- {{#if (eq auth "better-auth")}}
70
+ {{#if (and (eq auth "better-auth") (ne backend "convex"))}}
71
71
  <UserMenu />
72
72
  {{/if}}
73
73
  </div>
@@ -9,18 +9,18 @@
9
9
  "test": "vitest run"
10
10
  },
11
11
  "dependencies": {
12
- "@tailwindcss/vite": "^4.0.6",
13
- "@tanstack/router-plugin": "^1.109.2",
14
- "@tanstack/solid-form": "^1.9.0",
15
- "@tanstack/solid-router": "^1.110.0",
16
- "lucide-solid": "^0.507.0",
17
- "solid-js": "^1.9.4",
18
- "tailwindcss": "^4.0.6",
12
+ "@tailwindcss/vite": "^4.1.13",
13
+ "@tanstack/router-plugin": "^1.131.44",
14
+ "@tanstack/solid-form": "^1.20.0",
15
+ "@tanstack/solid-router": "^1.131.44",
16
+ "lucide-solid": "^0.544.0",
17
+ "solid-js": "^1.9.9",
18
+ "tailwindcss": "^4.1.13",
19
19
  "zod": "^4.0.2"
20
20
  },
21
21
  "devDependencies": {
22
- "typescript": "^5.7.2",
23
- "vite": "^7.0.2",
24
- "vite-plugin-solid": "^2.11.2"
22
+ "typescript": "^5.9.2",
23
+ "vite": "^7.1.5",
24
+ "vite-plugin-solid": "^2.11.8"
25
25
  }
26
26
  }
@@ -0,0 +1,6 @@
1
+ import { Polar } from "@polar-sh/sdk";
2
+
3
+ export const polarClient = new Polar({
4
+ accessToken: process.env.POLAR_ACCESS_TOKEN,
5
+ server: "sandbox",
6
+ });
@@ -0,0 +1,11 @@
1
+ <script setup lang="ts">
2
+ const route = useRoute()
3
+ const checkout_id = route.query.checkout_id as string
4
+ </script>
5
+
6
+ <template>
7
+ <div class="container mx-auto px-4 py-8">
8
+ <h1 class="text-2xl font-bold mb-4">Payment Successful!</h1>
9
+ <p v-if="checkout_id">Checkout ID: \{{ checkout_id }}</p>
10
+ </div>
11
+ </template>
@@ -0,0 +1,15 @@
1
+ export default async function SuccessPage({
2
+ searchParams,
3
+ }: {
4
+ searchParams: Promise<{ checkout_id: string }>
5
+ }) {
6
+ const params = await searchParams;
7
+ const checkout_id = params.checkout_id;
8
+
9
+ return (
10
+ <div className="px-4 py-8">
11
+ <h1>Payment Successful!</h1>
12
+ {checkout_id && <p>Checkout ID: {checkout_id}</p>}
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,13 @@
1
+ import { useSearchParams } from "react-router";
2
+
3
+ export default function SuccessPage() {
4
+ const [searchParams] = useSearchParams();
5
+ const checkout_id = searchParams.get("checkout_id");
6
+
7
+ return (
8
+ <div className="container mx-auto px-4 py-8">
9
+ <h1>Payment Successful!</h1>
10
+ {checkout_id && <p>Checkout ID: {checkout_id}</p>}
11
+ </div>
12
+ );
13
+ }
@@ -0,0 +1,19 @@
1
+ import { createFileRoute, useSearch } from "@tanstack/react-router";
2
+
3
+ export const Route = createFileRoute("/success")({
4
+ component: SuccessPage,
5
+ validateSearch: (search) => ({
6
+ checkout_id: search.checkout_id as string,
7
+ }),
8
+ });
9
+
10
+ function SuccessPage() {
11
+ const { checkout_id } = useSearch({ from: "/success" });
12
+
13
+ return (
14
+ <div className="container mx-auto px-4 py-8">
15
+ <h1>Payment Successful!</h1>
16
+ {checkout_id && <p>Checkout ID: {checkout_id}</p>}
17
+ </div>
18
+ );
19
+ }
@@ -0,0 +1,19 @@
1
+ import { createFileRoute, useSearch } from "@tanstack/react-router";
2
+
3
+ export const Route = createFileRoute("/success")({
4
+ component: SuccessPage,
5
+ validateSearch: (search) => ({
6
+ checkout_id: search.checkout_id as string,
7
+ }),
8
+ });
9
+
10
+ function SuccessPage() {
11
+ const { checkout_id } = useSearch({ from: "/success" });
12
+
13
+ return (
14
+ <div className="container mx-auto px-4 py-8">
15
+ <h1>Payment Successful!</h1>
16
+ {checkout_id && <p>Checkout ID: {checkout_id}</p>}
17
+ </div>
18
+ );
19
+ }
@@ -0,0 +1,23 @@
1
+ import { createFileRoute } from "@tanstack/solid-router";
2
+ import { Show } from "solid-js";
3
+
4
+ export const Route = createFileRoute("/success")({
5
+ component: SuccessPage,
6
+ validateSearch: (search) => ({
7
+ checkout_id: search.checkout_id as string,
8
+ }),
9
+ });
10
+
11
+ function SuccessPage() {
12
+ const searchParams = Route.useSearch();
13
+ const checkout_id = searchParams().checkout_id;
14
+
15
+ return (
16
+ <div class="container mx-auto px-4 py-8">
17
+ <h1>Payment Successful!</h1>
18
+ <Show when={checkout_id}>
19
+ <p>Checkout ID: {checkout_id}</p>
20
+ </Show>
21
+ </div>
22
+ );
23
+ }
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import { page } from '$app/stores';
3
+
4
+ const checkout_id = $page.url.searchParams.get('checkout_id');
5
+ </script>
6
+
7
+ <div class="container mx-auto px-4 py-8">
8
+ <h1>Payment Successful!</h1>
9
+ {#if checkout_id}
10
+ <p>Checkout ID: {checkout_id}</p>
11
+ {/if}
12
+ </div>
@@ -1,16 +0,0 @@
1
- import { createAuthClient } from "better-auth/vue";
2
-
3
- export default defineNuxtPlugin(nuxtApp => {
4
- const config = useRuntimeConfig()
5
- const serverUrl = config.public.serverURL
6
-
7
- const authClient = createAuthClient({
8
- baseURL: serverUrl
9
- })
10
-
11
- return {
12
- provide: {
13
- authClient: authClient
14
- }
15
- }
16
- })
@@ -1,11 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import { ThemeProvider as NextThemesProvider } from "next-themes"
5
-
6
- export function ThemeProvider({
7
- children,
8
- ...props
9
- }: React.ComponentProps<typeof NextThemesProvider>) {
10
- return <NextThemesProvider {...props}>{children}</NextThemesProvider>
11
- }
@@ -1,5 +0,0 @@
1
- import { createAuthClient } from "better-auth/solid";
2
-
3
- export const authClient = createAuthClient({
4
- baseURL: import.meta.env.VITE_SERVER_URL,
5
- });