Course contentsShow
← React
Lesson 200 of 2,3966. Component BasicsFree lesson

File Naming Conventions

Common patterns for naming component files: PascalCase.jsx, index.js, and kebab-case approaches.

File Naming Conventions

What you'll learn: How to name your React component files consistently using common community patterns.

Once you've settled on PascalCase for component names and chosen between named or default exports, you need to decide how to name the files those components live in. Unlike component names (which must be PascalCase), file names have more flexibility—but consistency matters.

The Three Common Patterns

PascalCase.jsx (or .js)

Match your file name exactly to your component name: UserProfile.jsx contains UserProfile. This is the most explicit approach—you instantly know what's in the file. It's especially popular when using named exports.

components/
  UserProfile.jsx  ← contains UserProfile component
  Button.jsx       ← contains Button component

index.js Pattern

Create a folder named after your component (in kebab-case or PascalCase), then use index.js as the file name:

components/
  user-profile/
    index.js  ← contains UserProfile component
  button/
    index.js  ← contains Button component

This works well when components need related files (styles, tests, subcomponents) grouped together. Importing stays clean: import UserProfile from './user-profile'.

kebab-case.jsx

Use lowercase with hyphens: user-profile.jsx contains UserProfile. Some teams prefer this for visual distinction from component names or alignment with URL conventions.

Which Should You Use?

All three are valid. PascalCase.jsx is trending as the most popular in modern React projects because it matches component names exactly, but many established codebases use index.js for organization. Pick one pattern and stick with it across your entire project.

Key Takeaway: File naming conventions are flexible, but consistency is crucial—choose PascalCase.jsx, index.js folders, or kebab-case and use it everywhere.