Creating New Components
AI-Assisted Component Creation
-
Create a new component file
new-component/index.tsx
in thecomponents
directory. -
In Cursor, use screenshots + prompts to let AI assist in generating new component code.
Prompt
follow this screenshot, create a react function component for me, use shadcn/ui, tailwindcss
- Import the new component in the page file
app/[locale]/default/new-page/page.tsx
.
app/[locale]/default/new-page/page.tsx
import { LoginForm } from "@/components/new-component";
export const runtime = "edge";
export default function NewPage() {
return (
<div className="container py-36 flex items-center justify-center">
<LoginForm />
</div>
);
}
- Visit the page route to see the new component in action.
It is recommended to place reusable components in the
components/blocks
directory, and business components in thecomponents
directory.