mirror of
https://github.com/vercel-labs/json-render.git
synced 2026-10-20 06:19:57 +08:00
Fixes a React runtime error where `useRef` was null due to multiple React instances being bundled. ## Changes Made - **Vite configuration**: Added `resolve.dedupe` for `react` and `react-dom` in `examples/mcp/vite.config.ts` to ensure only one instance of React is used during bundling - **React version constraints**: Changed from exact versions (`19.2.3`) to flexible ranges (`^19.0.0`) in `examples/mcp/package.json` to improve compatibility - **Build entry point**: Added new `build-app-html-entry.ts` file and updated `tsup.config.ts` to include it as a build target - **Package exports**: Added `./build-app-html` export path in `packages/mcp/package.json` - **Minor fixes**: Updated Next.js type reference path in stripe-app example The root cause was React being duplicated in the bundle, causing hooks like `useRef` to fail when components tried to access React's internal state from the wrong instance. The `dedupe` configuration ensures Vite resolves all React imports to the same module instance. Fixes #190
Stripe App API
A lightweight Next.js server that provides the /api/generate endpoint for AI-powered UI generation in the Stripe App examples.
Setup
pnpm install
cp .env.example .env
# Set AI_GATEWAY_API_KEY
Running
pnpm dev
Runs on port 3001. The Stripe apps (drawer-app/ and fullpage-app/) expect this server to be running for AI generation features.
API
POST /api/generate
Accepts { prompt, systemPrompt } and returns a streamed text response with a json-render spec.