create-better-t-stack 1.2.0 → 1.3.1
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 +52 -38
- package/dist/index.js +61 -55
- package/package.json +1 -1
- package/template/base/apps/native/_gitignore +24 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/_layout.tsx +29 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/index.tsx +9 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/two.tsx +16 -0
- package/template/base/apps/native/app/(drawer)/_layout.tsx +39 -0
- package/template/base/apps/native/app/(drawer)/index.tsx +36 -0
- package/template/base/apps/native/app/+html.tsx +46 -0
- package/template/base/apps/native/app/+not-found.tsx +18 -0
- package/template/base/apps/native/app/_layout.tsx +76 -0
- package/template/base/apps/native/app/modal.tsx +15 -0
- package/template/base/apps/native/app-env.d.ts +2 -0
- package/template/base/apps/native/app.json +38 -0
- package/template/base/apps/native/assets/adaptive-icon.png +0 -0
- package/template/base/apps/native/assets/favicon.png +0 -0
- package/template/base/apps/native/assets/icon.png +0 -0
- package/template/base/apps/native/assets/splash.png +0 -0
- package/template/base/apps/native/babel.config.js +12 -0
- package/template/base/apps/native/components/container.tsx +9 -0
- package/template/base/apps/native/components/header-button.tsx +31 -0
- package/template/base/apps/native/components/tabbar-icon.tsx +15 -0
- package/template/base/apps/native/global.css +25 -0
- package/template/base/apps/native/lib/android-navigation-bar.tsx +11 -0
- package/template/base/apps/native/lib/constants.ts +18 -0
- package/template/base/apps/native/lib/use-color-scheme.ts +12 -0
- package/template/base/apps/native/metro.config.js +57 -0
- package/template/base/apps/native/package.json +47 -0
- package/template/base/apps/native/tailwind.config.js +32 -0
- package/template/base/apps/native/tsconfig.json +18 -0
- package/template/base/apps/native/utils/trpc.ts +19 -0
- package/template/base/apps/{client → web}/package.json +1 -1
- package/template/base/apps/web/src/main.tsx +33 -0
- package/template/base/apps/{client → web}/src/routes/__root.tsx +3 -3
- package/template/base/apps/{client → web}/src/routes/index.tsx +7 -6
- package/template/base/apps/web/src/utils/trpc.ts +33 -0
- package/template/base/package.json +2 -1
- package/template/with-auth/apps/{client → web}/src/routes/dashboard.tsx +2 -1
- package/template/with-auth/apps/web/src/utils/trpc.ts +39 -0
- package/template/base/apps/client/src/main.tsx +0 -72
- package/template/base/apps/client/src/utils/trpc.ts +0 -4
- package/template/with-auth/apps/client/src/main.tsx +0 -78
- /package/template/base/apps/{client → web}/_gitignore +0 -0
- /package/template/base/apps/{client → web}/components.json +0 -0
- /package/template/base/apps/{client → web}/index.html +0 -0
- /package/template/base/apps/{client → web}/src/components/header.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/loader.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/mode-toggle.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/theme-provider.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/button.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/card.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/checkbox.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/dropdown-menu.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/input.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/label.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/skeleton.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/sonner.tsx +0 -0
- /package/template/base/apps/{client → web}/src/index.css +0 -0
- /package/template/base/apps/{client → web}/src/lib/utils.ts +0 -0
- /package/template/base/apps/{client → web}/tsconfig.json +0 -0
- /package/template/base/apps/{client → web}/vite.config.ts +0 -0
- /package/template/examples/todo/apps/{client → web}/src/routes/todos.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/auth-forms.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/header.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/sign-in-form.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/sign-up-form.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/user-menu.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/lib/auth-client.ts +0 -0
- /package/template/with-auth/apps/{client → web}/src/routes/login.tsx +0 -0
- /package/template/with-pwa/apps/{client → web}/public/logo.png +0 -0
- /package/template/with-pwa/apps/{client → web}/pwa-assets.config.ts +0 -0
- /package/template/with-pwa/apps/{client → web}/vite.config.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
2
|
+
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
3
|
+
import ReactDOM from "react-dom/client";
|
|
4
|
+
import Loader from "./components/loader";
|
|
5
|
+
import { routeTree } from "./routeTree.gen";
|
|
6
|
+
import { queryClient, trpcClient } from "./utils/trpc";
|
|
7
|
+
|
|
8
|
+
const router = createRouter({
|
|
9
|
+
routeTree,
|
|
10
|
+
defaultPreload: "intent",
|
|
11
|
+
defaultPendingComponent: () => <Loader />,
|
|
12
|
+
context: { trpcClient },
|
|
13
|
+
Wrap: function WrapComponent({ children }) {
|
|
14
|
+
return (
|
|
15
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Register things for typesafety
|
|
21
|
+
declare module "@tanstack/react-router" {
|
|
22
|
+
interface Register {
|
|
23
|
+
router: typeof router;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const rootElement = document.getElementById("app");
|
|
28
|
+
if (!rootElement) throw new Error("Root element not found");
|
|
29
|
+
|
|
30
|
+
if (!rootElement.innerHTML) {
|
|
31
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
32
|
+
root.render(<RouterProvider router={router} />);
|
|
33
|
+
}
|
|
@@ -2,19 +2,19 @@ import Header from "@/components/header";
|
|
|
2
2
|
import Loader from "@/components/loader";
|
|
3
3
|
import { ThemeProvider } from "@/components/theme-provider";
|
|
4
4
|
import { Toaster } from "@/components/ui/sonner";
|
|
5
|
-
import {
|
|
5
|
+
import type { trpcClient } from "@/utils/trpc";
|
|
6
6
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
7
7
|
import {
|
|
8
|
+
HeadContent,
|
|
8
9
|
Outlet,
|
|
9
10
|
createRootRouteWithContext,
|
|
10
11
|
useRouterState,
|
|
11
|
-
HeadContent,
|
|
12
12
|
} from "@tanstack/react-router";
|
|
13
13
|
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
14
14
|
import "../index.css";
|
|
15
15
|
|
|
16
16
|
export interface RouterAppContext {
|
|
17
|
-
|
|
17
|
+
trpcClient: typeof trpcClient;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const Route = createRootRouteWithContext<RouterAppContext>()({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Button } from "@/components/ui/button";
|
|
1
2
|
import { trpc } from "@/utils/trpc";
|
|
2
|
-
import {
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { Link, createFileRoute } from "@tanstack/react-router";
|
|
3
5
|
import { ArrowRight } from "lucide-react";
|
|
4
|
-
import { Button } from "@/components/ui/button";
|
|
5
6
|
|
|
6
7
|
export const Route = createFileRoute("/")({
|
|
7
8
|
component: HomeComponent,
|
|
@@ -24,7 +25,7 @@ const TITLE_TEXT = `
|
|
|
24
25
|
`;
|
|
25
26
|
|
|
26
27
|
function HomeComponent() {
|
|
27
|
-
const healthCheck = trpc.healthCheck.
|
|
28
|
+
const healthCheck = useQuery(trpc.healthCheck.queryOptions());
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
31
|
<div className="container mx-auto max-w-3xl px-4 py-2">
|
|
@@ -33,9 +34,9 @@ function HomeComponent() {
|
|
|
33
34
|
<section className="rounded-lg border p-4">
|
|
34
35
|
<h2 className="mb-2 font-medium">API Status</h2>
|
|
35
36
|
<div className="flex items-center gap-2">
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
<div
|
|
38
|
+
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
|
39
|
+
/>
|
|
39
40
|
<span className="text-sm text-muted-foreground">
|
|
40
41
|
{healthCheck.isLoading
|
|
41
42
|
? "Checking..."
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AppRouter } from "../../../server/src/routers";
|
|
2
|
+
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
4
|
+
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
|
|
7
|
+
export const queryClient = new QueryClient({
|
|
8
|
+
queryCache: new QueryCache({
|
|
9
|
+
onError: (error) => {
|
|
10
|
+
toast.error(error.message, {
|
|
11
|
+
action: {
|
|
12
|
+
label: "retry",
|
|
13
|
+
onClick: () => {
|
|
14
|
+
queryClient.invalidateQueries();
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const trpcClient = createTRPCClient<AppRouter>({
|
|
23
|
+
links: [
|
|
24
|
+
httpBatchLink({
|
|
25
|
+
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
31
|
+
client: trpcClient,
|
|
32
|
+
queryClient,
|
|
33
|
+
});
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"dev": "turbo dev",
|
|
7
7
|
"build": "turbo build",
|
|
8
8
|
"check-types": "turbo check-types",
|
|
9
|
-
"dev:
|
|
9
|
+
"dev:native": "turbo -F native dev",
|
|
10
|
+
"dev:web": "turbo -F web dev",
|
|
10
11
|
"dev:server": "turbo -F server dev",
|
|
11
12
|
"db:push": "turbo -F server db:push",
|
|
12
13
|
"db:studio": "turbo -F server db:studio"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { authClient } from "@/lib/auth-client";
|
|
2
2
|
import { trpc } from "@/utils/trpc";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
4
|
import { createFileRoute } from "@tanstack/react-router";
|
|
4
5
|
import { useEffect } from "react";
|
|
5
6
|
|
|
@@ -12,7 +13,7 @@ function RouteComponent() {
|
|
|
12
13
|
|
|
13
14
|
const navigate = Route.useNavigate();
|
|
14
15
|
|
|
15
|
-
const privateData = trpc.privateData.
|
|
16
|
+
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
16
17
|
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
if (!session && !isPending) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AppRouter } from "../../../server/src/routers";
|
|
2
|
+
import { QueryCache, QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
4
|
+
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
|
|
7
|
+
export const queryClient = new QueryClient({
|
|
8
|
+
queryCache: new QueryCache({
|
|
9
|
+
onError: (error) => {
|
|
10
|
+
toast.error(error.message, {
|
|
11
|
+
action: {
|
|
12
|
+
label: "retry",
|
|
13
|
+
onClick: () => {
|
|
14
|
+
queryClient.invalidateQueries();
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const trpcClient = createTRPCClient<AppRouter>({
|
|
23
|
+
links: [
|
|
24
|
+
httpBatchLink({
|
|
25
|
+
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
26
|
+
fetch(url, options) {
|
|
27
|
+
return fetch(url, {
|
|
28
|
+
...options,
|
|
29
|
+
credentials: "include",
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const trpc = createTRPCOptionsProxy<AppRouter>({
|
|
37
|
+
client: trpcClient,
|
|
38
|
+
queryClient,
|
|
39
|
+
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QueryCache,
|
|
3
|
-
QueryClient,
|
|
4
|
-
QueryClientProvider,
|
|
5
|
-
} from "@tanstack/react-query";
|
|
6
|
-
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
7
|
-
import { httpBatchLink } from "@trpc/client";
|
|
8
|
-
import { createTRPCQueryUtils } from "@trpc/react-query";
|
|
9
|
-
import ReactDOM from "react-dom/client";
|
|
10
|
-
import { toast } from "sonner";
|
|
11
|
-
import Loader from "./components/loader";
|
|
12
|
-
import { routeTree } from "./routeTree.gen";
|
|
13
|
-
import { trpc } from "./utils/trpc";
|
|
14
|
-
|
|
15
|
-
const queryClient = new QueryClient({
|
|
16
|
-
queryCache: new QueryCache({
|
|
17
|
-
onError: (error) => {
|
|
18
|
-
toast.error(error.message, {
|
|
19
|
-
action: {
|
|
20
|
-
label: "retry",
|
|
21
|
-
onClick: () => {
|
|
22
|
-
queryClient.invalidateQueries();
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const trpcClient = trpc.createClient({
|
|
31
|
-
links: [
|
|
32
|
-
httpBatchLink({
|
|
33
|
-
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export const trpcQueryUtils = createTRPCQueryUtils({
|
|
39
|
-
queryClient,
|
|
40
|
-
client: trpcClient,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const router = createRouter({
|
|
44
|
-
routeTree,
|
|
45
|
-
defaultPreload: "intent",
|
|
46
|
-
context: { trpcQueryUtils },
|
|
47
|
-
defaultPendingComponent: () => <Loader />,
|
|
48
|
-
Wrap: function WrapComponent({ children }) {
|
|
49
|
-
return (
|
|
50
|
-
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
51
|
-
<QueryClientProvider client={queryClient}>
|
|
52
|
-
{children}
|
|
53
|
-
</QueryClientProvider>
|
|
54
|
-
</trpc.Provider>
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Register things for typesafety
|
|
60
|
-
declare module "@tanstack/react-router" {
|
|
61
|
-
interface Register {
|
|
62
|
-
router: typeof router;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const rootElement = document.getElementById("app");
|
|
67
|
-
if (!rootElement) throw new Error("Root element not found");
|
|
68
|
-
|
|
69
|
-
if (!rootElement.innerHTML) {
|
|
70
|
-
const root = ReactDOM.createRoot(rootElement);
|
|
71
|
-
root.render(<RouterProvider router={router} />);
|
|
72
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QueryCache,
|
|
3
|
-
QueryClient,
|
|
4
|
-
QueryClientProvider,
|
|
5
|
-
} from "@tanstack/react-query";
|
|
6
|
-
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
7
|
-
import { httpBatchLink } from "@trpc/client";
|
|
8
|
-
import { createTRPCQueryUtils } from "@trpc/react-query";
|
|
9
|
-
import ReactDOM from "react-dom/client";
|
|
10
|
-
import { toast } from "sonner";
|
|
11
|
-
import Loader from "./components/loader";
|
|
12
|
-
import { routeTree } from "./routeTree.gen";
|
|
13
|
-
import { trpc } from "./utils/trpc";
|
|
14
|
-
|
|
15
|
-
const queryClient = new QueryClient({
|
|
16
|
-
queryCache: new QueryCache({
|
|
17
|
-
onError: (error) => {
|
|
18
|
-
toast.error(error.message, {
|
|
19
|
-
action: {
|
|
20
|
-
label: "retry",
|
|
21
|
-
onClick: () => {
|
|
22
|
-
queryClient.invalidateQueries();
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const trpcClient = trpc.createClient({
|
|
31
|
-
links: [
|
|
32
|
-
httpBatchLink({
|
|
33
|
-
url: `${import.meta.env.VITE_SERVER_URL}/trpc`,
|
|
34
|
-
fetch(url, options) {
|
|
35
|
-
return fetch(url, {
|
|
36
|
-
...options,
|
|
37
|
-
credentials: "include",
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export const trpcQueryUtils = createTRPCQueryUtils({
|
|
45
|
-
queryClient,
|
|
46
|
-
client: trpcClient,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const router = createRouter({
|
|
50
|
-
routeTree,
|
|
51
|
-
defaultPreload: "intent",
|
|
52
|
-
context: { trpcQueryUtils },
|
|
53
|
-
defaultPendingComponent: () => <Loader />,
|
|
54
|
-
Wrap: function WrapComponent({ children }) {
|
|
55
|
-
return (
|
|
56
|
-
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
57
|
-
<QueryClientProvider client={queryClient}>
|
|
58
|
-
{children}
|
|
59
|
-
</QueryClientProvider>
|
|
60
|
-
</trpc.Provider>
|
|
61
|
-
);
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Register things for typesafety
|
|
66
|
-
declare module "@tanstack/react-router" {
|
|
67
|
-
interface Register {
|
|
68
|
-
router: typeof router;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const rootElement = document.getElementById("app");
|
|
73
|
-
if (!rootElement) throw new Error("Root element not found");
|
|
74
|
-
|
|
75
|
-
if (!rootElement.innerHTML) {
|
|
76
|
-
const root = ReactDOM.createRoot(rootElement);
|
|
77
|
-
root.render(<RouterProvider router={router} />);
|
|
78
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|