rename folder

This commit is contained in:
sanjeed5
2025-02-27 00:04:07 +05:30
parent 519c3fa882
commit f7fa52c998
879 changed files with 0 additions and 0 deletions
@@ -0,0 +1,15 @@
---
description: Rules for data fetching in server components in Next.js 14.
globs: **/app/**/*.tsx
---
- For data fetching in server components (in .tsx files):
tsx
async function getData() {
const res = await fetch('<https://api.example.com/data>', { next: { revalidate: 3600 } })
if (!res.ok) throw new Error('Failed to fetch data')
return res.json()
}
export default async function Page() {
const data = await getData()
// Render component using data
}
@@ -0,0 +1,20 @@
---
description: Rules for implementing error handling in Next.js 14 using error.tsx files.
globs: **/app/error.tsx
---
- For error handling (in error.tsx):
tsx
'use client'
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
return (
);
}
@@ -0,0 +1,9 @@
---
description: Apply general guidelines for Next.js 14 code generation.
globs: **/*.*
---
- Assume the user has already set up the Next.js project with Tailwind CSS.
- Use environment variables for configuration following Next.js conventions.
- Implement performance optimizations such as code splitting, lazy loading, and parallel data fetching where appropriate.
- Ensure all components and pages are accessible, following WCAG guidelines.
- Utilize Next.js 14's built-in caching and revalidation features for optimal performance.
@@ -0,0 +1,11 @@
---
description: Rules for defining metadata in Next.js 14 components for SEO optimization.
globs: **/app/**/*.tsx
---
- For metadata (in .tsx files):
tsx
import type { Metadata } from 'next'
export const metadata: Metadata = {
title: 'Page Title',
description: 'Page description',
}
@@ -0,0 +1,17 @@
---
description: General rules for Next.js 14 development, including using the app directory, server components, and modern TypeScript syntax.
globs: **/app/**/*.*
---
- Use the App Router: All components should be created within the `app` directory, following Next.js 14 conventions.
- Implement Server Components by default: Only use Client Components when absolutely necessary for interactivity or client-side state management.
- Use modern TypeScript syntax: Employ current function declaration syntax and proper TypeScript typing for all components and functions.
- Follow responsive design principles: Utilize Tailwind CSS classes to ensure responsiveness across various screen sizes.
- Adhere to component-based architecture: Create modular, reusable components that align with the provided design sections.
- Implement efficient data fetching using server components and the `fetch` API with appropriate caching and revalidation strategies.
- Use Next.js 14's metadata API for SEO optimization.
- Employ Next.js Image component for optimized image loading.
- Ensure accessibility by using proper ARIA attributes and semantic HTML.
- Implement error handling using error boundaries and error.tsx files.
- Use loading.tsx files for managing loading states.
- Utilize route handlers (route.ts) for API routes in the App Router.
- Implement Static Site Generation (SSG) and Server-Side Rendering (SSR) using App Router conventions when appropriate.
@@ -0,0 +1,5 @@
---
description: Rules for using Tailwind CSS for styling in Next.js 14 components.
globs: **/*.tsx
---
- Utilize Tailwind CSS classes exclusively for styling. Avoid inline styles.
@@ -0,0 +1,51 @@
---
description: Rules for generating TypeScript code in Next.js 14 components, including component definition syntax, props definitions, and named/default exports.
globs: **/*.tsx
---
- Always use TypeScript for type safety. Provide appropriate type definitions and interfaces.
- Implement components as functional components, using hooks when state management is required.
- Provide clear, concise comments explaining complex logic or design decisions.
- Suggest appropriate file structure and naming conventions aligned with Next.js 14 best practices.
- Use the `'use client'` directive only when creating Client Components.
- Employ the following component definition syntax in .tsx files, allowing TypeScript to infer the return type:
tsx
const ComponentName = () => {
// Component logic
};
- For props, use interface definitions:
tsx
interface ComponentNameProps {
// Props definition
}
const ComponentName = ({ prop1, prop2 }: ComponentNameProps) => {
// Component logic
};
- Use named exports for components in .tsx files:
tsx
export const ComponentName = () => {
// Component logic
};
- For page components, use default exports in .tsx files:
tsx
const Page = () => {
// Page component logic
};
export default Page;
- If explicit typing is needed, prefer `React.FC` or `React.ReactNode`:
tsx
import React from 'react';
const ComponentName: React.FC = () => {
// Component logic
};
// OR
const ComponentName = (): React.ReactNode => {
// Component logic
};
- When defining React components, avoid unnecessary type annotations and let TypeScript infer types when possible.
- Use `React.FC` or `React.ReactNode` for explicit typing only when necessary, avoiding `JSX.Element`.
- Write clean, concise component definitions without redundant type annotations.