Generate React components from natural language using the Cursor SDK and Next.js 14.
- Install dependencies:
npm install- Copy the environment template and add your API key:
cp .env.local.example .env.localGet a key from Cursor Dashboard → Integrations.
- Start the dev server:
npm run devOpen http://localhost:3000.
| Variable | Description |
|---|---|
CURSOR_API_KEY |
Cursor API key (server-side only) |
- Client: Chat panel + output panel (preview/code tabs) via
useGeneratehook - API:
POST /api/generatestreams SSE deltas from@cursor/sdk - Preview: iframe with Babel standalone + React UMD + Tailwind CDN
- Syntax highlighting: Shiki with tokyo-night theme
npm run dev # Development server
npm run build # Production build
npm run start # Production server
npm run lint # ESLint
npx tsc --noEmit # Type checkUI follows tokens in DESIGN.md (Cursor design system via getdesign).
- Authentication and user accounts
- Chat persistence
- Redis-backed rate limiting (in-memory limit resets on cold start)
- Export to CodeSandbox
The API allows 10 requests per minute per IP using an in-memory map. For production, replace with Redis or a similar store.
@cursor/sdk depends on sqlite3, which requires native bindings. If generation fails with a bindings error, run npm rebuild sqlite3 (Visual Studio Build Tools may be required) or install on WSL/Linux.