Skip to content

02:convex package - #1

Merged
ladaniprem merged 1 commit into
masterfrom
02-convex-package
Jun 7, 2026
Merged

ladaniprem merged 1 commit into
masterfrom
02-convex-package

Conversation

@ladaniprem

@ladaniprem ladaniprem commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added user management functionality with the ability to add and view users in the application.
    • Integrated backend data fetching and mutation capabilities across web and widget apps.
  • Bug Fixes

    • Resolved hydration mismatch warnings in application layouts.
  • Changes

    • Simplified theme configuration with updated defaults.
    • Removed theme toggle keyboard shortcut functionality.
    • Updated data display formatting for improved readability.

Copilot AI review requested due to automatic review settings June 7, 2026 08:02
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: bc6cfccb-c93e-4e57-a299-1b4e13598c6c

📥 Commits

Reviewing files that changed from the base of the PR and between 053107a and e588931.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • apps/web/app/layout.tsx
  • apps/web/app/page.tsx
  • apps/web/components/theme-provider.tsx
  • apps/web/tsconfig.json
  • apps/widget/app/layout.tsx
  • apps/widget/app/page.tsx
  • apps/widget/components/theme-provider.tsx
  • apps/widget/package.json
  • apps/widget/tsconfig.json
  • packages/backend/convex/users.ts

📝 Walkthrough

Walkthrough

This 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.

Changes

Convex Integration across Backend and Apps

Layer / File(s) Summary
Backend users mutation
packages/backend/convex/users.ts
The Convex users module now imports mutation and exports a new add mutation that inserts a user with name "prem" and returns the inserted ID.
Configuration and path aliases
apps/web/tsconfig.json, apps/widget/tsconfig.json, apps/widget/package.json
TypeScript path aliases in both apps are updated to point to packages/backend/convex/*; widget's tsconfig gains baseUrl and ignoreDeprecations options, and widget's dependencies now include @workspace/backend.
Web app: Convex client and theme provider
apps/web/components/theme-provider.tsx, apps/web/app/layout.tsx
The web theme provider initializes a ConvexReactClient from NEXT_PUBLIC_CONVEX_URL and wraps children with ConvexProvider, removing prior hotkey-based theme toggling. Layout adds suppressHydrationWarning to the body element.
Web app: Page component with user query and mutation
apps/web/app/page.tsx
The page imports useQuery and useMutation, wires the UI to api.users.getMany (query) and api.users.add (mutation), and renders users as pretty-printed JSON with an "Add User" button.
Widget app: Convex client and theme provider
apps/widget/components/theme-provider.tsx, apps/widget/app/layout.tsx
The widget theme provider initializes ConvexReactClient and wraps children with ConvexProvider using hardcoded next-themes config (no hotkey logic or props forwarding). Layout is reformatted and adds suppressHydrationWarning to body.
Widget app: Page component with user query and mutation
apps/widget/app/page.tsx
The page adds "use client" directive and uses useQuery/useMutation to fetch and mutate users, rendering the data as pretty-printed JSON with an "Add User" button and a centered app label.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A backend blooms with mutations bright,
Two apps now dance in Convex light,
With hooks they fetch, with buttons send,
Theme and user data blend.
From convex clouds to JSON streams,
We build a user-fetching dream! ✨


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands and usage tips.

@ladaniprem
ladaniprem merged commit 50f3750 into master Jun 7, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/backend and convex dependencies to apps/widget and updates lockfile accordingly.
  • Introduces a users Convex query and mutation in the backend and consumes them from apps/web and apps/widget pages.
  • 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 || "");
Comment on lines +9 to 17
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 || "");
Comment on lines +9 to +12
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}>
Comment thread apps/widget/app/page.tsx
Comment on lines +11 to +13
<p>apps/widget</p>
<Button onClick={() => addUser()}>Add User</Button>
<div className="max-w-sm w-full mx-auto">
Comment thread apps/web/app/page.tsx
Comment on lines 10 to +12
<p>apps/web</p>
{JSON.stringify(users)}
<Button onClick={() => addUser()}>Add User</Button>
<div className="max-w-sm w-full mx-auto">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants