Skip to content

Commit 59b1a79

Browse files
02: convex package
1 parent e15a4f9 commit 59b1a79

27 files changed

Lines changed: 1346 additions & 178 deletions

apps/web/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Geist, Geist_Mono } from "next/font/google"
22

33
import "@workspace/ui/globals.css"
4-
import { ThemeProvider } from "@/components/theme-provider"
4+
import { Providers} from "@/components/providers"
55
import { cn } from "@workspace/ui/lib/utils";
66

77
const geist = Geist({subsets:['latin'],variable:'--font-sans'})
@@ -23,7 +23,7 @@ export default function RootLayout({
2323
className={cn("antialiased", fontMono.variable, "font-sans", geist.variable)}
2424
>
2525
<body>
26-
<ThemeProvider>{children}</ThemeProvider>
26+
<Providers>{children}</Providers>
2727
</body>
2828
</html>
2929
)

apps/web/app/page.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import { Button } from "@workspace/ui/components/button"
2-
import { add } from "@workspace/math/add"
1+
"use client"
2+
3+
import { useMutation, useQuery } from 'convex/react'
4+
import { api } from '@workspace/backend/_generated/api'
5+
import { Button } from '@workspace/ui/components/button'
36

47
export default function Page() {
8+
9+
const users = useQuery(api.users.getMany)
10+
const addUser = useMutation(api.users.add)
11+
12+
513
return (
6-
<div className="flex min-h-svh p-6">
7-
<div className="flex max-w-md min-w-0 flex-col gap-4 text-sm leading-loose">
8-
<div>
9-
<h1 className="font-medium">Project ready!</h1>
10-
<p>{add(1, 2)}</p>
11-
<Button className="mt-2">Button</Button>
12-
</div>
13-
<div className="text-muted-foreground font-mono text-xs">
14-
(Press <kbd>d</kbd> to toggle dark mode)
15-
</div>
16-
</div>
14+
<div className="flex flex-col items-center justify-center min-h-svh">
15+
<Button onClick={()=>addUser()}>Add User</Button>
16+
<p>apps/Web</p>
17+
<div className='max-w-sm w-full mx-auto'>
18+
{JSON.stringify(users, null , 2)}
19+
</div>
1720
</div>
1821
)
1922
}

apps/web/components/providers.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import { ConvexProvider, ConvexReactClient } from "convex/react";
5+
// import { ConvexProviderWithClerk } from 'convex/react-clerk'
6+
// import { useAuth } from '@clerk/nextjs'
7+
8+
// if (!process.env.NEXT_PUBLIC_CONVEX_URL) {
9+
// throw new Error('Missing NEXT_PUBLIC_CONVEX_URL in your .env file')
10+
// }
11+
12+
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL || "");
13+
14+
export function Providers({ children }: { children: React.ReactNode }) {
15+
return (
16+
<ConvexProvider client={convex}>{children}</ConvexProvider>
17+
18+
// <ConvexProviderWithClerk client={convex} useAuth={useAuth}>
19+
// {children}
20+
// </ConvexProviderWithClerk>
21+
);
22+
};

apps/web/components/theme-provider.tsx

Lines changed: 0 additions & 71 deletions
This file was deleted.

apps/web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
"typecheck": "tsc --noEmit"
1313
},
1414
"dependencies": {
15+
"@workspace/backend": "workspace:*",
1516
"@workspace/math": "workspace:*",
1617
"@workspace/ui": "workspace:*",
18+
"convex": "^1.35.1",
1719
"lucide-react": "^1.8.0",
1820
"next": "16.1.6",
1921
"next-themes": "^0.4.6",

apps/web/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"paths": {
66
"@/*": ["./*"],
77
"@workspace/ui/*": ["../../packages/ui/src/*"],
8-
"@workspace/math/*": ["../../packages/math/src/*"]
8+
"@workspace/math/*": ["../../packages/math/src/*"],
9+
"@workspace/backend/*": ["../../packages/backend/convex/*"],
910
},
1011
"plugins": [
1112
{

apps/widget/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Geist, Geist_Mono } from "next/font/google"
22

33
import "@workspace/ui/styles/globals.css"
4-
import { ThemeProvider } from "@/components/theme-provider"
4+
import { Providers } from "@/components/providers"
55
import { cn } from "@workspace/ui/lib/utils";
66

77
const geist = Geist({subsets:['latin'],variable:'--font-sans'})
@@ -23,7 +23,7 @@ export default function RootLayout({
2323
className={cn("antialiased", fontMono.variable, "font-sans", geist.variable)}
2424
>
2525
<body>
26-
<ThemeProvider>{children}</ThemeProvider>
26+
<Providers>{children}</Providers>
2727
</body>
2828
</html>
2929
)

apps/widget/app/page.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import { Button } from "@workspace/ui/components/button"
2-
import {add } from "@workspace/math/add"
3-
import { Input } from "@workspace/ui/components/input"
1+
"use client"
2+
3+
import { useMutation, useQuery } from 'convex/react'
4+
import { api } from '@workspace/backend/_generated/api'
5+
import { Button } from '@workspace/ui/components/button'
46

57
export default function Page() {
8+
9+
const users = useQuery(api.users.getMany)
10+
const addUser = useMutation(api.users.add)
11+
612
return (
7-
<div className="flex min-h-svh p-6">
8-
<div className="flex max-w-md min-w-0 flex-col gap-4 text-sm leading-loose">
9-
<div>
10-
<h1 className="font-medium">Project ready!</h1>
11-
<p>You may now add components and start building.</p>
12-
<p>We&apos;ve already added the button component for you.</p>
13-
<Button className="mt-2">Button</Button>
14-
</div>
15-
<div className="text-muted-foreground font-mono text-xs">
16-
(Press <kbd>d</kbd> to toggle dark mode)
17-
<p>{add(1, 2)}</p>
18-
</div>
19-
<Input/>
20-
</div>
13+
<div className="flex flex-col items-center justify-center min-h-svh">
14+
<Button onClick={()=>addUser()}>Add User</Button>
15+
<p>apps/widget</p>
16+
<div className='max-w-sm w-full mx-auto'>
17+
{JSON.stringify(users, null , 2)}
18+
</div>
2119
</div>
2220
)
2321
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import { ConvexProvider, ConvexReactClient } from "convex/react";
5+
// import { ConvexProviderWithClerk } from 'convex/react-clerk'
6+
// import { useAuth } from '@clerk/nextjs'
7+
8+
// if (!process.env.NEXT_PUBLIC_CONVEX_URL) {
9+
// throw new Error('Missing NEXT_PUBLIC_CONVEX_URL in your .env file')
10+
// }
11+
12+
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL || "");
13+
14+
export function Providers({ children }: { children: React.ReactNode }) {
15+
return (
16+
<ConvexProvider client={convex}>{children}</ConvexProvider>
17+
18+
// <ConvexProviderWithClerk client={convex} useAuth={useAuth}>
19+
// {children}
20+
// </ConvexProviderWithClerk>
21+
);
22+
};

apps/widget/components/theme-provider.tsx

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)