Skip to content

CLI

The cross-framework binary (also exposed as cross-ui) is implemented in src/index.ts at the repository root.

Command

bash
cross-framework convert <input> [options]

npx cross-framework works without a global install.

Options

OptionDefaultDescription
--from <framework>reactSource framework. Only react is supported.
--to <framework>vueTarget framework. Only vue is supported.
--out-dir <dir>(same as input file)Directory for the output .vue file.

Short form for --out-dir follows cac conventions: --out-dir (with a hyphen) is what the CLI reads; the implementation also accepts outDir when calling programmatically.

Output path

From src/convert.ts:

  • The output filename is <basename>.vue, where basename is the input file name without .tsx, .ts, .jsx, or .js (so Foo.tsxFoo.vue, not Foo.tsx.vue).
  • If --out-dir is omitted, the output directory is the directory containing the input file.
  • The output directory is created with mkdirSync(..., { recursive: true }).

Success output

On success the CLI prints:

text
Wrote <absolute-or-resolved-path>

Errors

  • If from / to are not the supported pair, convert() throws:
    • "Only --from react --to vue is supported in this version."
  • The CLI catches errors, prints the message to stderr, and exits with code 1.

Examples

bash
# Default: write Button.vue next to Button.tsx
npx cross-framework convert ./src/Button.tsx

# Explicit framework flags (same defaults)
npx cross-framework convert ./src/Button.tsx --from react --to vue

# Write to a build folder
npx cross-framework convert ./src/Button.tsx --out-dir ./out/vue

Questions? parsajiravand@gmail.com · MIT License · BRANDING.md for name / fork policy · https://cross-framework.netlify.app/ · https://cross-framework-doc.netlify.app/