kriziu nextjs-template .cursorrules file for TypeScript

You are an expert in TypeScript, Node.js, Next.js App Router, React, Drizzle ORM, PostgresSQL, Shadcn UI, Radix UI and Tailwind.

Code Style and Structure

- Write concise, technical TypeScript code with accurate examples.
- Use functional and declarative programming patterns.
- Write Clean Architecture code independently of any framework, testable and with low coupling.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Structure files: exported component, subcomponents, helpers, static content, types.

Naming Conventions

- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor default exports for components.

TypeScript Usage

- Use TypeScript for all code; prefer types over interfaces. Use interfaces only for repository/services definitions.
- Avoid enums; use maps instead.
- Use functional components with TypeScript types.

Syntax and Formatting

- Use the "function" keyword for pure functions.
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
- Use declarative JSX.

UI and Styling

- Use Shadcn UI, Radix, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS.

Performance Optimization

- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC).
- Wrap client components in Suspense with fallback.
- Use dynamic loading for non-critical components.
- Optimize images: use WebP format, include size data, implement lazy loading.

Key Conventions

- Use 'nuqs' for URL search parameter state management.
- Optimize Web Vitals (LCP, CLS, FID).
- Limit 'use client':
  - Favor server components and Next.js SSR.
  - Use only for Web API access in small components.
  - Avoid for data fetching or state management.

Clean Architecture

- Use /app folder only for Next.js and react (UI) specific code
- Use /src folder for the business logic (application layer, entities layer, infrastructure layer and interface-adapters layer)
- Use /di folder for dependency injection
- Use /tests folder for tests that matches the /src folder structure
- Use /drizzle folder for database related code (models, schema, etc.)

Follow Next.js docs for Data Fetching, Rendering, and Routing.
css
dockerfile
drizzle-orm
javascript
next.js
postgresql
radix-ui
react
+3 more

First Time Repository

A fullstack template to start with

TypeScript

Languages:

CSS: 1.8KB
Dockerfile: 0.7KB
JavaScript: 0.3KB
TypeScript: 94.3KB
Created: 8/5/2024
Updated: 9/8/2024

All Repositories (1)

A fullstack template to start with