A Next.js App Router example demonstrating @rightbrain/sdk integration with TypeScript (via a server-side proxy) and JavaScript (via a direct Node.js client).
src/
app/
api/tasks/route.ts # Server-side proxy endpoint
page.tsx # Demo UI
components/
prd-analysis-form.tsx # Text-only task example
profile-photo-verification-form.tsx # Image task example
product-listing-form.tsx # Text + image task example
generated/
index.ts # Auto-generated types from task definitions
lib/
rightbrain.ts # SDK client setup (PublicTransport)
use-task.ts # React hook for task execution
direct-transport/
index.js # Standalone Node.js example (DirectTransport)
rb-tasks/ # YAML task definitions
scripts/
setup-tasks.mjs # Task creation script
rightbrain.json # CLI configuration
pnpm installnpx rightbrain@latest loginpnpm setup-tasksCreates three tasks in your RightBrain project and appends their IDs to .env.
npx rightbrain@latest initSelect the tasks created in step 3. Ignore the warning about an existing config file.
Generates src/generated/index.ts with fully-typed task interfaces based on your task definitions.
pnpm devThe direct-transport/ directory contains a standalone Node.js script that uses DirectTransport to call a task without a server-side proxy. It requires the same env vars as the Next.js app plus dotenvx (already a dependency).
pnpm direct-transportThis reads from .env and runs the GenerateImageBasedProductListing task against a bundled sample image.
TypeScript errors after setup:
If you renamed tasks during creation, the generated types may not match. Either:
- Re-run
pnpm generate-tasksafter ensuring task names match - Update component files to use the correct generated type names
Missing environment variables:
Ensure your .env file contains all required variables. The setup-tasks script populates the NEXT_PUBLIC_*_TASK_ID vars automatically. RB_ORG_ID, RB_PROJECT_ID, and RB_API_KEY are written by npx rightbrain@latest login and npx rightbrain@latest init.