kitcn 0.12.5 → 0.12.7
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/aggregate/index.d.ts +1 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +15 -15
- package/dist/auth/start/index.d.ts +1 -0
- package/dist/auth/start/index.js +1 -0
- package/dist/cli.mjs +837 -31
- package/dist/{codegen-lF80HSWu.mjs → codegen-B60fOYhd.mjs} +17 -13
- package/dist/crpc/index.d.ts +1 -1
- package/dist/{generated-contract-disabled-D-sOFy92.d.ts → generated-contract-disabled-Cf7sqlVD.d.ts} +30 -30
- package/dist/orm/index.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/ratelimit/index.d.ts +1 -1
- package/dist/rsc/index.d.ts +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-1H1v2Cai.d.ts → where-clause-compiler-ner2TQ3O.d.ts} +80 -80
- package/package.json +2 -1
- package/skills/convex/references/features/auth.md +1 -1
- package/skills/convex/references/setup/start.md +61 -18
- /package/dist/{middleware-BUybuv9n.d.ts → middleware-BL2wn3s0.d.ts} +0 -0
- /package/dist/{types-HhO_R6pd.d.ts → types-BLvtq_eH.d.ts} +0 -0
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
## 8.B TanStack Start
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
CLI-first flow: scaffold the app, run `kitcn add auth --yes`, then treat the
|
|
4
|
+
files below as the generated reference output. They are not a separate manual
|
|
5
|
+
install path.
|
|
5
6
|
### 8.B.1 Auth client + auth server helpers
|
|
6
7
|
|
|
7
|
-
**Create:** `src/lib/convex/auth
|
|
8
|
+
**Create:** `src/lib/convex/auth-client.ts`
|
|
8
9
|
|
|
9
10
|
```ts
|
|
10
|
-
import type { Auth } from "@convex/auth-shared";
|
|
11
|
-
import { convexClient } from "@convex-dev/better-auth/client/plugins";
|
|
12
|
-
import { adminClient, inferAdditionalFields } from "better-auth/client/plugins";
|
|
13
11
|
import { createAuthClient } from "better-auth/react";
|
|
12
|
+
import { convexClient } from "kitcn/auth/client";
|
|
13
|
+
import { createAuthMutations } from "kitcn/react";
|
|
14
14
|
|
|
15
15
|
export const authClient = createAuthClient({
|
|
16
16
|
baseURL:
|
|
17
17
|
typeof window === "undefined"
|
|
18
18
|
? (import.meta.env.VITE_SITE_URL as string | undefined)
|
|
19
19
|
: window.location.origin,
|
|
20
|
-
|
|
21
|
-
plugins: [inferAdditionalFields<Auth>(), adminClient(), convexClient()],
|
|
20
|
+
plugins: [convexClient()],
|
|
22
21
|
});
|
|
22
|
+
|
|
23
|
+
export const {
|
|
24
|
+
useSignInMutationOptions,
|
|
25
|
+
useSignOutMutationOptions,
|
|
26
|
+
useSignUpMutationOptions,
|
|
27
|
+
} = createAuthMutations(authClient);
|
|
23
28
|
```
|
|
24
29
|
|
|
25
|
-
**Create:** `src/lib/convex/auth
|
|
30
|
+
**Create:** `src/lib/convex/auth-server.ts`
|
|
26
31
|
|
|
27
32
|
```ts
|
|
28
|
-
import { convexBetterAuthReactStart } from "
|
|
33
|
+
import { convexBetterAuthReactStart } from "kitcn/auth/start";
|
|
29
34
|
|
|
30
35
|
export const {
|
|
31
36
|
handler,
|
|
@@ -34,8 +39,8 @@ export const {
|
|
|
34
39
|
fetchAuthMutation,
|
|
35
40
|
fetchAuthAction,
|
|
36
41
|
} = convexBetterAuthReactStart({
|
|
37
|
-
convexUrl:
|
|
38
|
-
convexSiteUrl:
|
|
42
|
+
convexUrl: import.meta.env.VITE_CONVEX_URL!,
|
|
43
|
+
convexSiteUrl: import.meta.env.VITE_CONVEX_SITE_URL!,
|
|
39
44
|
});
|
|
40
45
|
```
|
|
41
46
|
|
|
@@ -45,9 +50,9 @@ export const {
|
|
|
45
50
|
|
|
46
51
|
```ts
|
|
47
52
|
import { createFileRoute } from "@tanstack/react-router";
|
|
48
|
-
import { handler } from "@/lib/convex/auth
|
|
53
|
+
import { handler } from "@/lib/convex/auth-server";
|
|
49
54
|
|
|
50
|
-
export const Route = createFileRoute("/api/auth/$")({
|
|
55
|
+
export const Route = createFileRoute("/api/auth/$" as never)({
|
|
51
56
|
server: {
|
|
52
57
|
handlers: {
|
|
53
58
|
GET: ({ request }) => handler(request),
|
|
@@ -59,9 +64,47 @@ export const Route = createFileRoute("/api/auth/$")({
|
|
|
59
64
|
|
|
60
65
|
### 8.B.3 Caller/context and providers
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
**Create:** `src/lib/convex/server.ts`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { api } from "@convex/api";
|
|
71
|
+
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
72
|
+
import { createCallerFactory } from "kitcn/server";
|
|
73
|
+
|
|
74
|
+
import { getToken } from "@/lib/convex/auth-server";
|
|
75
|
+
|
|
76
|
+
const { createContext, createCaller } = createCallerFactory({
|
|
77
|
+
api,
|
|
78
|
+
convexSiteUrl: import.meta.env.VITE_CONVEX_SITE_URL!,
|
|
79
|
+
auth: {
|
|
80
|
+
getToken: async () => {
|
|
81
|
+
return {
|
|
82
|
+
token: await getToken(),
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
type ServerCaller = ReturnType<typeof createCaller>;
|
|
89
|
+
|
|
90
|
+
async function makeContext() {
|
|
91
|
+
const headers = await getRequestHeaders();
|
|
92
|
+
return createContext({ headers });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function createServerCaller(): ServerCaller {
|
|
96
|
+
return createCaller(async () => {
|
|
97
|
+
return await makeContext();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function runServerCall<T>(fn: (caller: ServerCaller) => Promise<T> | T) {
|
|
102
|
+
const caller = createServerCaller();
|
|
103
|
+
return fn(caller);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
63
106
|
|
|
64
|
-
|
|
65
|
-
- router context values (`convex`, `queryClient`, `convexQueryClient`)
|
|
66
|
-
- provider wrapping with `ConvexAuthProvider` and `initialToken`
|
|
107
|
+
Use the docs pattern from `tanstack-start.mdx` for:
|
|
67
108
|
|
|
109
|
+
- `src/routes/__root.tsx` shell/provider wiring
|
|
110
|
+
- `src/lib/convex/convex-provider.tsx`
|
|
File without changes
|
|
File without changes
|