### Deploy Convex Schema and Start Frontend Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Commands to install backend dependencies, deploy the Convex schema, install frontend dependencies, and start the development server. ```bash cd backend npm install npx convex deploy cd frontend npm install npm run dev ``` -------------------------------- ### Docker Compose Up Command Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Starts all defined Docker services in detached mode for the application. ```bash docker compose up -d ``` -------------------------------- ### Example Convex Function (TypeScript) Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/custom-instructions.md Demonstrates the structure of a Convex query function in TypeScript. It includes argument validation using `convex/values` and defines a return type. This pattern is essential for defining backend logic in Convex. ```typescript import { query } from "./_generated/server"; import { v } from "convex/values"; export const getUser = query({ args: { id: v.id("users") }, returns: v.object({ _id: v.id("users"), _creationTime: v.number(), name: v.string(), email: v.string(), }), handler: async (ctx, args) => { const user = await ctx.db.get(args.id); if (!user) throw new Error("User not found"); return user; }, }); ``` -------------------------------- ### Backend .env.local Configuration with Keycloak Details Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Provides a comprehensive backend .env.local configuration including Convex, Keycloak, token validation, and rate limiting settings. ```bash # Convex configuration CONVEX_SELF_HOSTED_URL=http://localhost:3210 CONVEX_SELF_HOSTED_ADMIN_KEY=your_generated_admin_key # Keycloak configuration for backend validation KEYCLOAK_URL=http://localhost:8080 KEYCLOAK_REALM=master KEYCLOAK_CLIENT_ID=vite-app # Token validation settings TOKEN_EXPIRATION_GRACE_PERIOD_SECONDS=30 MAX_TOKEN_AGE_SECONDS=86400 # Rate limiting settings RATE_LIMITING_WINDOW_MS=60000 RATE_LIMITING_MAX_REQUESTS=5 ``` -------------------------------- ### Backend Configuration (.env) Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Defines essential issuers, client IDs, audiences, and sources for token validation and client access in the backend. ```bash VALID_ISSUERS=http://localhost:8080/realms/master,http://keycloak:8080/realms/master,https://localhost:8443/realms/master VALID_CLIENT_IDS=vite-app VALID_AUDIENCES=master-realm,account VALID_SOURCES=vite-app,master-realm ``` -------------------------------- ### Backend .env.local Configuration Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Sets environment variables for the Convex backend, including self-hosted URL and admin key. ```bash CONVEX_SELF_HOSTED_URL=http://localhost:3210 CONVEX_SELF_HOSTED_ADMIN_KEY=your_admin_key_here ``` -------------------------------- ### Frontend Configuration (.env.local) Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Configures the frontend connection to Convex and Keycloak authentication settings. ```dotenv # Convex URL for client connection VITE_CONVEX_URL=http://localhost:3210 # Keycloak configuration for frontend authentication VITE_KEYCLOAK_URL=http://localhost:8080 VITE_KEYCLOAK_REALM=master VITE_KEYCLOAK_CLIENT_ID=vite-app ``` -------------------------------- ### Convex Function Syntax and Registration (TypeScript) Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/custom-instructions.md Illustrates the standard syntax for defining Convex functions using the new syntax. It covers defining arguments, return types, and the handler function, emphasizing the use of `query`, `mutation`, or `action`. ```typescript import { query } from "./_generated/server"; import { v } from "convex/values"; export const functionName = query({ args: { /* validators */ }, returns: v.object({ /* return type validators */ }), handler: async (ctx, args) => { // Function body }, }); ``` -------------------------------- ### Deploy Backend Changes Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Command to deploy changes made to the Convex backend functions. ```bash cd backend npx convex deploy ``` -------------------------------- ### Frontend .env.local Configuration Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Configures frontend environment variables for Keycloak integration, specifying the URL, realm, and client ID. ```bash VITE_KEYCLOAK_URL=http://localhost:8080 VITE_KEYCLOAK_REALM=master VITE_KEYCLOAK_CLIENT_ID=vite-app ``` -------------------------------- ### React User Profile Component with Convex Data Fetching (TypeScript) Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/custom-instructions.md A React component demonstrating how to fetch user data using Convex's `useQuery` hook and display it with shadcn/ui components and Tailwind CSS. It includes basic loading state handling. Dependencies: React, Convex, shadcn/ui, Tailwind CSS. ```typescript import React from 'react'; import { Button } from "@/components/ui/button"; import { useQuery } from "convex/react"; import { api } from "@backend/convex/_generated/api"; type UserProfileProps = { userId: string; }; export const UserProfile: React.FC = ({ userId }) => { const user = useQuery(api.users.getUser, { id: userId }); if (!user) return
Loading...
; return (

{user.name}

); }; ``` -------------------------------- ### Generate Convex Admin Key Source: https://github.com/vintuvishal/convex-react-keycloak-monorepo/blob/main/README.md Executes a script within the backend Docker container to generate a Convex admin key. ```bash docker compose exec backend bash -c "cd /convex && ./generate_admin_key.sh" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.