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
The React file you want to convert. Supports
.tsx, .ts, .jsx, and .js files.Output file path. If not specified, the original file is overwritten.Examples:
--output ./converted/MyComponent.tsx-o ../next-version/Header.tsx
Comma-separated list of transformations to apply. Available options:
router- React Router to Next.js navigationhelmet- React Helmet to Next.js Headclient- Auto-detect and add ‘use client’ directivecontext- React Context provider migrationall- Apply all transformations (default)
--transform router--transform router,client-t helmet,context
Preview changes without modifying any files. Great for testing.Example:
Show a detailed before/after comparison. Must be used with
--dry-run.Example:List all available transformations and exit.Example:
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:
- 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 themTest Individual Transformations
Use
--transform to apply specific changes and understand what each doesKeep Backups
Use
--output to save converted files separately when testingStart 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
Explore real-world conversion examples
2
Learn Full Migration
Ready for complete project migration? See the migrate command
3
Read Best Practices
Check out our best practices guide
