Skip to main content
The convert command consumes 1 file conversion credit per file. Each new account starts with 10 free conversion credits, and every migration credit purchased grants 10 additional conversion credits.

Basic Usage

Examples

Simple Conversion

Convert a single file:

Preview Changes First

See what will change without modifying the file:

Convert with Specific Transformations

Apply only specific transformation types:

Save to Different Location

Keep the original file intact:

Command Options

string
required
The React file you want to convert. Supports .tsx, .ts, .jsx, and .js files.
string
Output file path. If not specified, the original file is overwritten.Examples:
  • --output ./converted/MyComponent.tsx
  • -o ../next-version/Header.tsx
string
Comma-separated list of transformations to apply. Available options:
  • router - React Router to Next.js navigation
  • helmet - React Helmet to Next.js Head
  • client - Auto-detect and add ‘use client’ directive
  • context - React Context provider migration
  • all - Apply all transformations (default)
Examples:
  • --transform router
  • --transform router,client
  • -t helmet,context
boolean
Preview changes without modifying any files. Great for testing.Example:
boolean
Show a detailed before/after comparison. Must be used with --dry-run.Example:
boolean
List all available transformations and exit.Example:
boolean
Show help information for the convert command.

Transformation Types

router

Converts React Router usage to Next.js navigation:

helmet

Converts React Helmet to Next.js Head:

client

Automatically detects when a component needs the 'use client' directive:
Client directive is added when the component uses:
  • React hooks (useState, useEffect, etc.)
  • Event handlers (onClick, onChange, etc.)
  • Browser APIs (window, document, localStorage)
  • Third-party libraries that require client-side execution

context

Migrates React Context providers and consumers:

Common Use Cases

Testing Before Full Migration

Before migrating an entire project, test key components:

Batch Processing

Convert multiple files at once:

Incremental Migration

Gradually migrate your codebase:

Output Examples

Dry Run Output

Diff Output

Tips & Best Practices

Always Preview First

Use --dry-run --show-diff to see changes before applying them

Test Individual Transformations

Use --transform to apply specific changes and understand what each does

Keep Backups

Use --output to save converted files separately when testing

Start Small

Begin with simple components before tackling complex files

Error Handling

The convert command includes robust error handling:
  • Syntax errors: The tool will report and skip files with syntax errors
  • Unsupported patterns: Complex patterns are reported for manual review
  • File permissions: Clear error messages for permission issues
  • Invalid options: Helpful suggestions for incorrect command usage

What’s Next?

1

Try More Examples

2

Learn Full Migration

Ready for complete project migration? See the migrate command
3

Read Best Practices

Check out our best practices guide