Skip to content

Naming Conventions

Consistent naming makes code easier to read and find. When every file follows the same pattern, developers can predict where to find things.

ConventionExampleWhen to Use
kebab-casepost-list.tsxFile names (all files)
PascalCasePostList.tsxComponent files
camelCaseusePosts.tsHook files, utilities
dot notationposts.route.tsNext.js special files
components/
├── ui/
│ ├── button.tsx # kebab-case
│ ├── post-list.tsx # kebab-case
│ ├── CreatePostForm.tsx # PascalCase (component)
│ └── index.ts # Barrel export
hooks/
├── use-posts.ts # kebab-case
├── use-user.ts
lib/
├── api-client.ts # kebab-case
├── utils.ts
// ✅ Descriptive component names
export function PostList() { }
export function UserAvatar() { }
export function CreatePostForm() { }
// ❌ Generic names
export function List() { }
export function Avatar() { }
export function Form() { }
// ✅ Descriptive
const isLoading = true
const sortedPosts = posts.sort()
async function fetchUser(id: string) { }
// ❌ Unclear
const flag = true
const data = posts.sort()
async function get(id: string) { }
features/
├── auth/ # kebab-case
├── user-profile/ # kebab-case — use full words
├── billing/ # kebab-case
└── src/ # ❌ avoid abbreviations like 'src' in feature folders
  • Mixed casing — Pick one convention and use it everywhere. Mixing snake_case and camelCase is confusing.
  • Abbreviations — usr, btn, cfg are unclear. Use full words: user, button, config.
  • Generic names — index.tsx everywhere loses meaning. Use descriptive component names.
  • Use kebab-case for all files (except components which are PascalCase)
  • Use descriptive, full-word names
  • Be consistent across the entire project — use linting to enforce
  • Group related files with consistent prefixes (use- for hooks)

Consistent naming conventions make codebases predictable and easy to navigate. Use kebab-case for files, PascalCase for components, and descriptive names everywhere. Enforce conventions with linting.