02:convex package - #1
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThis PR integrates Convex as a backend-of-frontend for a Next.js monorepo, adding a user mutation to the backend and wiring both web and widget apps to query and mutate user data through shared Convex React hooks initialized in their theme providers. ChangesConvex Integration across Backend and Apps
Sequence DiagramsequenceDiagram
participant App as Web/Widget App
participant ThemeProvider
participant ConvexReactClient
participant ConvexProvider
participant Page
participant api as Convex API
App->>ThemeProvider: Wrap with ThemeProvider
ThemeProvider->>ConvexReactClient: Create client from NEXT_PUBLIC_CONVEX_URL
ThemeProvider->>ConvexProvider: Wrap children with ConvexProvider
ConvexProvider-->>App: Provide Convex context
Page->>api: useQuery(api.users.getMany)
api-->>Page: Return users list
Page->>Page: Render users as JSON
App->>Page: Click "Add User" button
Page->>api: useMutation(api.users.add)
api->>api: Insert user into table
api-->>Page: Return new user ID
Page->>Page: Re-fetch and update display
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces Convex into the monorepo by wiring up a shared Convex backend module and integrating Convex React client/provider usage into the web and widget Next.js apps.
Changes:
- Adds
@workspace/backendandconvexdependencies toapps/widgetand updates lockfile accordingly. - Introduces a
usersConvex query and mutation in the backend and consumes them fromapps/webandapps/widgetpages. - Updates TS path aliases in both apps to resolve Convex-generated API types from
packages/backend/convex.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks added workspace dependency and convex in the widget app. |
| packages/backend/convex/users.ts | Adds users.getMany query and users.add mutation. |
| apps/widget/tsconfig.json | Adds TS path alias to backend Convex sources (and baseUrl/ignoreDeprecations). |
| apps/widget/package.json | Adds @workspace/backend and convex dependencies. |
| apps/widget/components/theme-provider.tsx | Wraps app in ConvexProvider alongside next-themes provider. |
| apps/widget/app/page.tsx | Uses Convex useQuery/useMutation to list/add users. |
| apps/widget/app/layout.tsx | Minor layout adjustments (hydration warning + formatting changes). |
| apps/web/tsconfig.json | Adjusts backend alias to point at backend Convex sources. |
| apps/web/components/theme-provider.tsx | Wraps app in ConvexProvider alongside next-themes provider. |
| apps/web/app/page.tsx | Adds mutation usage + button to insert a user. |
| apps/web/app/layout.tsx | Minor layout adjustments (hydration warning + formatting changes). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { ThemeProvider as NextThemesProvider } from "next-themes" | ||
| import { ConvexProvider, ConvexReactClient } from "convex/react" | ||
|
|
||
| const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL || ""); |
| export function ThemeProvider({ children }: React.ComponentProps<typeof NextThemesProvider>) { | ||
| return ( | ||
| <NextThemesProvider attribute="class" defaultTheme="light" enableSystem themes={["light", "dark"]}> | ||
| <ConvexProvider client={convex}> | ||
| {children} | ||
| </ConvexProvider> | ||
| </NextThemesProvider> | ||
| ) | ||
| } |
| if (!(target instanceof HTMLElement)) { | ||
| return false | ||
| } | ||
| const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL || ""); |
| export function ThemeProvider({ children }: React.ComponentProps<typeof NextThemesProvider>) { | ||
| return ( | ||
| target.isContentEditable || | ||
| target.tagName === "INPUT" || | ||
| target.tagName === "TEXTAREA" || | ||
| target.tagName === "SELECT" | ||
| <NextThemesProvider attribute="class" defaultTheme="light" enableSystem themes={["light", "dark"]}> | ||
| <ConvexProvider client={convex}> |
| <p>apps/widget</p> | ||
| <Button onClick={() => addUser()}>Add User</Button> | ||
| <div className="max-w-sm w-full mx-auto"> |
| <p>apps/web</p> | ||
| {JSON.stringify(users)} | ||
| <Button onClick={() => addUser()}>Add User</Button> | ||
| <div className="max-w-sm w-full mx-auto"> |
Summary by CodeRabbit
New Features
Bug Fixes
Changes