Course contentsShow
← React
Lesson 2330 of 2,39651. TypeScript with React BasicsFree lesson

Props Interface vs Type Alias

Understand when to use interface vs type for defining component props and the practical differences.

Props Interface vs Type Alias

What you'll learn: When to choose interface or type for defining React component props and what actually differs between them.

The Core Question

Both interface and type can define your props shape in TypeScript. For most React scenarios, they're interchangeable—but there are subtle practical differences worth knowing.

Basic Usage: They Look Similar

// Using interface
interface ButtonProps {
  label: string;
  onClick: () => void;
}

// Using type
type ButtonProps = {
  label: string;
  onClick: () => void;
};

// Both work identically here
function Button(props: ButtonProps) {
  return <button onClick={props.onClick}>{props.label}</button>;
}

When to Prefer Interface

Declaration merging is interface's superpower. If you define the same interface twice, TypeScript merges them:

interface BaseProps {
  id: string;
}

interface BaseProps {
  className?: string;
}

// Merged result has both properties

This matters for library authors or when extending third-party types. It's also the React team's convention.

When to Prefer Type

Union types and complex transformations require type:

type Status = 'loading' | 'success' | 'error';

type ButtonProps = {
  variant: 'primary' | 'secondary';
} & CommonProps; // intersection

The Pragmatic Answer

For everyday React props, use interface by convention. The React ecosystem defaults to it, and you'll see it in most codebases. Switch to type only when you need unions, intersections, or mapped types that interface can't express.

Key Takeaway: Both interface and type work for props, but interface is the React convention for simple object shapes, while type is necessary for unions and complex type operations.