Code Snippets
Fetch API (async/await)
async function fetchData() {
try {
const res = await fetch('/api/data');
const data = await res.json();
console.log(data);
} catch (err) {
console.error('Fetch error:', err);
}
}Reusable Components
Button Primary
import { Button } from "@/components/ui/button";
export function PrimaryButton({ label, onClick }) {
return (
<Button
onClick={onClick}
className="bg-blue-600 hover:bg-blue-700 text-white rounded-lg"
>
{label}
</Button>
);
}Commands & Scripts
Project Setup
# Install dependencies npm install # Run dev server npm run dev # Format code npm run format