DEV Community

Cover image for πŸš€ Stop Rewriting Components β€” Convert React to Vue Automatically
Parsa Jiravand
Parsa Jiravand

Posted on

πŸš€ Stop Rewriting Components β€” Convert React to Vue Automatically

What if switching frameworks didn’t mean rewriting everything from scratch?

Frontend developers are constantly facing this problem:

  • You start with React, then your team (or client) prefers Vue
  • You want to reuse logic across ecosystems
  • Or you're exploring frameworks but hate duplicating effort

So I built something to challenge that.

πŸ”₯ Introducing: cross-framework

A source-to-source compiler that converts:

πŸ‘‰ React (JSX / TSX) β†’ Vue 3 (Single File Components)

And no β€” this is not regex hacks or AI guessing.

This is a real compiler pipeline:

  • Parse code using Babel
  • Transform into an intermediate representation (IR)
  • Emit clean Vue 3 <script setup> + <template>

πŸŽ₯ Demo (see it in action)

Watch the demo here:
https://x.com/i/status/2037575942160122244


🧠 Why this matters

Switching frameworks today is expensive:

  • Rewriting components manually
  • Risk of introducing bugs
  • Losing consistency across codebases

AI tools try to solve this, but:

  • ❌ Results are inconsistent
  • ❌ Require prompt engineering
  • ❌ Break structure in complex cases
  • ❌ Come with ongoing pricing plans

This project focuses on:
βœ” deterministic output
βœ” structured transformations
βœ” developer-first control


βš™οΈ How it works

CLI usage

npm install cross-framework
Enter fullscreen mode Exit fullscreen mode
npx cross-framework convert --from react --to vue ./path/Component.tsx
Enter fullscreen mode Exit fullscreen mode

This generates:

Component.vue
Enter fullscreen mode Exit fullscreen mode

You can also specify an output directory with --out-dir.


Programmatic API

import { convertCode } from "cross-framework"

const vueCode = convertCode({
  from: "react",
  to: "vue",
  sourceCode: reactSource,
  filename: "Component.tsx",
})
Enter fullscreen mode Exit fullscreen mode

🧩 What it supports

βœ… React Features

  • Function components (default / named exports)
  • memo and forwardRef

βœ… Hooks β†’ Vue equivalents

  • useState β†’ ref
  • useRef β†’ ref
  • useMemo β†’ computed
  • useEffect β†’ watch, watchEffect, onMounted

βœ… JSX β†’ Vue Template

  • Props & spreads
  • Events
  • Lists (map)
  • Conditionals
  • Fragments

All transformed into clean Vue 3 template syntax:

  • className β†’ class / :class
  • JSX β†’ template IR β†’ Vue output

⚠️ Current limitations

Like any early-stage compiler, there are some constraints:

  • Imports are not rewritten
  • Multi-component files may need manual adjustments
  • Design-system-heavy props might need cleanup

🌍 Try it yourself

πŸ§ͺ Playground:
https://cross-framework.netlify.app/

πŸ“š Documentation:
https://cross-framework-doc.netlify.app/


🧭 The vision

This is just the beginning.

Next steps:

  • Support more frameworks (Angular, Svelte, etc.)
  • Convert entire projects, not just components
  • Build a universal transformation pipeline for frontend code

Imagine:

Write once β†’ run anywhere (React, Vue, more…)


❀️ Support the project

If you believe in this direction and want to see it grow:

πŸ‘‰ https://github.com/sponsors/parsajiravand


🀝 Join the team

I’m looking for developers who want to build something ambitious in the frontend ecosystem.

If you're interested in contributing long-term:

πŸ“© parsajiravand@gmail.com


🧠 Final thought

We’ve spent years choosing frameworks.

Maybe it’s time to stop choosing…
and start abstracting the boundaries between them.

#webdevelopment #frontend #reactjs #vuejs #javascript #typescript #opensource #programming #softwareengineering #developer #coding #devtools #saas #ai #buildinpublic #100daysofcode #github #webdev #frontenddeveloper #techinnovation

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.